# Managing people, access and sites

> The write side of the organization API: create members, issue and suspend cards and licence plates, define access groups and schedules, set up facilities and doors, read access events and receive them as webhooks. Every access change reports which controllers confirmed it.

With an [organization API key](/docs/api-keys/overview/) your own system can run day-to-day access control: who the members are, what they carry, which doors it opens and when, and what happened at those doors. This page covers those endpoints. Reading passes, facilities and the member directory is on [Organization API](/docs/api-reference/organization/).

**Base:** `https://entrybit.net` · **Auth:** `Authorization: Bearer eb_sk_…` · the rules every endpoint shares are in [Conventions](/docs/api-reference/conventions/).

Three things hold everywhere on this page:

- **Unknown fields are refused by name.** The error carries `param`, so a typo never looks like a change that was made.
- **A change to access reports its delivery.** See [Delivery](#delivery).
- **Creating is safe to retry.** Send an [`Idempotency-Key`](/docs/api-reference/conventions/#safe-retries).

## Members

A member is a person who can hold credentials. Reading members is on [Organization API](/docs/api-reference/organization/#list-members).

### Create a member

```http
POST /api/v1/org/members
```

**Scope:** `org:members:write`.

```bash
curl -X POST https://entrybit.net/api/v1/org/members \
  -H "Authorization: Bearer $ENTRYBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 0f9b6c1e-5a52-4d0c-9d35-6f1f6c1f7a10" \
  -d '{ "first_name": "Dana", "last_name": "Levi", "phone": "+972501234567", "external_id": "resident-17" }'
```

| Field | Notes |
|---|---|
| `first_name` | Required. |
| `last_name`, `email`, `phone` | Optional. |
| `external_id` | Your own reference: up to 64 printable ASCII characters with no spaces, unique in the organization. |

A second member with the same `external_id` is `409 external_id_taken`, and the error carries `member_id`, the member that already has it. Find a member by it with `GET /api/v1/org/members?external_id=resident-17`.

The response is the [Member object](/docs/api-reference/organization/#the-member-object), now with `external_id`. Email and phone are returned only to a key that also holds `org:members:contact:read`.

### Change or deactivate a member

```http
PATCH /api/v1/org/members/{id}
```

Send only what changes; `null` clears a field.

`"status": "inactive"` deactivates the member. Every one of their credentials is removed from the controllers at once and the response carries `delivery`. `"status": "active"` puts their active credentials back. The record, and each credential's own status, are kept either way.

### Delete a member

```http
DELETE /api/v1/org/members/{id}
```

Permanent. Their credentials are removed from every controller. To keep the record and only stop access, deactivate instead.

## Credentials

A credential is what a controller recognises: a card or a licence plate. Which doors it opens comes from its [access group](#access-groups).

### Issue a credential

```http
POST /api/v1/org/members/{id}/credentials
```

**Scope:** `org:credentials:write`.

```bash
curl -X POST https://entrybit.net/api/v1/org/members/emp_7b2d1ac98ef04c35/credentials \
  -H "Authorization: Bearer $ENTRYBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 6c5c2f0a-1a0b-4a57-8a67-4d6e0b7a2f11" \
  -d '{
    "type": "card", "value": "12345678", "label": "Blue fob",
    "valid_from": "2026-12-01T00:00:00+02:00", "valid_until": "2027-12-01T00:00:00+02:00",
    "access_group_id": 4
  }'
```

`type` is `card` or `plate`. Administrator credentials, PINs and QR codes are issued in the app and cannot be created here. Times must carry an offset.

```json
{
  "success": true,
  "credential": {
    "id": "0c1f…", "object": "credential", "type": "card", "value": "12345678", "label": "Blue fob",
    "status": "active", "valid_from": "2026-11-30T22:00:00+00:00", "valid_until": "2027-11-30T22:00:00+00:00",
    "access_group_id": 4, "created_at": "2026-11-26T09:00:00+00:00"
  },
  "delivery": {
    "status": "pending",
    "controllers": [ { "sn": "A1B2C3", "confirmed": true }, { "sn": "D4E5F6", "confirmed": false } ]
  }
}
```

### Change, suspend or resume

```http
PATCH /api/v1/org/members/{id}/credentials/{credential_id}
```

Change `label`, `valid_from`, `valid_until`, `access_group_id` or `status`. An omitted validity bound keeps the stored one; `null` clears it.

`"status": "suspended"` removes the credential from the controllers at once. `"status": "active"` puts it back.

### Delete

```http
DELETE /api/v1/org/members/{id}/credentials/{credential_id}
```

`GET /api/v1/org/members/{id}/credentials` (`org:credentials:read`) lists a member's credentials.

## Delivery

A change to what a credential can open is stored first and then sent to the controllers. Every such response reports the sending.

| `delivery.status` | Meaning |
|---|---|
| `confirmed` | Every controller acknowledged the change. |
| `pending` | At least one did not answer, usually because it is offline. It applies the change when it reconnects; a removal is queued durably and is applied before anything else. |
| `not_required` | There was no controller to tell. |

A request waits up to five seconds for each controller, so allow for a slower answer when one is unreachable.

To see whether a pending change has since been confirmed, ask again:

```http
GET /api/v1/org/members/{id}/credentials/{credential_id}/delivery
```

```json
{
  "success": true, "object": "credential_delivery", "credential_id": "0c1f…",
  "status": "pending", "wanted": "absent",
  "controllers": [
    { "sn": "A1B2C3", "confirmed": true,  "confirmed_at": "2026-12-01T10:00:02+00:00", "last_attempt_at": "2026-12-01T10:00:02+00:00" },
    { "sn": "D4E5F6", "confirmed": false, "confirmed_at": null, "last_attempt_at": "2026-12-01T10:00:07+00:00" }
  ]
}
```

`wanted` is what the controllers should hold now: `absent` for a suspended credential or one whose member is deactivated. A controller counts as confirmed only if it confirmed that same wish, so a card that was confirmed present and is then suspended reads `pending` until its removal is confirmed. `unknown` means nothing has been recorded yet.

## Access groups

An access group says **which doors, and when**. A credential opens the doors of the group it is given. This is the only way the API grants doors: there is no per-member door list.

```http
POST /api/v1/org/access-groups
```

**Scope:** `org:access:write`.

```bash
curl -X POST https://entrybit.net/api/v1/org/access-groups \
  -H "Authorization: Bearer $ENTRYBIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Residents",
    "doors": [
      { "controller_sn": "A1B2C3", "door_no": 0 },
      { "controller_sn": "A1B2C3", "door_no": 2,
        "schedule": { "mon": { "start": "06:00", "end": "23:00" }, "tue": { "start": "06:00", "end": "23:00" } } }
    ]
  }'
```

Doors are named as [`GET /api/v1/org/controllers`](#controllers-and-doors) lists them. A door takes its own `schedule`, else the request's top-level `schedule`, else it is open at all hours. In a schedule a day that is left out is closed, times are `HH:MM`, and the start must be before the end. A door that does not belong to the organization is refused by name; it is never silently dropped.

| Endpoint | Notes |
|---|---|
| `GET /api/v1/org/access-groups` | `org:access:read`. Groups with their doors and hours. |
| `PATCH /api/v1/org/access-groups/{id}` | Change `name`, `description` or `doors` (which replaces the whole list). When the doors change, every credential already in the group is brought up to date and sent to the controllers; `credentials_updated` says how many. |
| `DELETE /api/v1/org/access-groups/{id}` | Refused with `409 access_group_in_use` while any credential is assigned to it. |

## Facilities

A facility is a place guests are invited to: a name, opening hours, and the doors a guest pass opens. A pass cannot be issued for a facility without doors.

| Endpoint | Notes |
|---|---|
| `POST /api/v1/org/facilities` | `org:facilities:write`. Body: `name`, `schedule` (required), `description`, `slot_minutes`, `capacity_per_slot`, `doors`. Validated exactly as the app's own form. |
| `GET /api/v1/org/facilities/{id}` | `org:facilities:read`. One facility with its doors. |
| `PATCH /api/v1/org/facilities/{id}` | Send only what changes. `doors` replaces the whole list. Passes already issued keep the doors they were issued with. |
| `DELETE /api/v1/org/facilities/{id}` | Takes the facility out of use: future bookings are cancelled and its passes stop working. |

## Controllers and doors

`GET /api/v1/org/controllers` (`org:controllers:read`) lists controllers with their doors and whether each is online. It is where `controller_sn` and `door_no` come from.

```http
PATCH /api/v1/org/doors
```

**Scope:** `org:doors:write`. Renames a door, changes how long it stays released, or both.

```json
{ "controller_sn": "A1B2C3", "door_no": 1, "name": "Lobby", "open_seconds": 7 }
```

`POST /api/v1/org/doors/open` (`org:doors:open`) momentarily opens a door.

## Access events

```http
GET /api/v1/org/events
```

**Scope:** `org:events:read`. What happened at the doors, newest first.

| Query | Notes |
|---|---|
| `limit` | 1 to 200, default 50. |
| `cursor` | `next_cursor` from the previous page. |
| `occurred_after`, `occurred_before` | ISO 8601 with an offset. `after` is inclusive, `before` exclusive. |
| `controller_sn`, `door_no` | One controller; one door on it. |
| `outcome` | `granted` or `denied`. |
| `member_id` | Only this member's events. |
| `pass_id` | Only this guest pass's events. Not together with `member_id`. |

```json
{
  "success": true, "object": "list", "has_more": true, "next_cursor": "WyIyMDI2…",
  "data": [{
    "id": "rec_3kQ9…", "object": "access_event",
    "occurred_at": "2026-12-01T10:00:00+02:00",
    "type": "door", "outcome": "granted",
    "reason_code": 1, "reason": "Access granted",
    "controller_sn": "A1B2C3", "door_no": 2, "door_name": "Lobby",
    "member": { "id": "emp_7b2d1ac98ef04c35", "name": "Dana Levi" },
    "credential": { "id": "0c1f…", "type": "card", "name": "Blue fob" }
  }]
}
```

`type` is `door`, `button`, `fire`, `forced_entry` or `command`. `outcome` is set only for a decision about a person or vehicle. `member` and `credential` are `null` when the card is unknown.

### Guest arrival

A guest is marked `checked_in`, with `checked_in_at` set to the time of the scan, the first time their pass is accepted at a door. `GET /api/v1/org/passes` returns `status`, `checked_in_at` and `checked_out_at` for each pass.

Leaving is not inferred from a scan: a door does not record which way someone walked through it. A guest is checked out by a person in the app, or by the nightly close of the day.

## Webhooks

Be told about access events as they happen instead of polling.

```http
POST /api/v1/org/webhooks
```

**Scope:** `org:webhooks:write`.

```json
{ "url": "https://hooks.example.com/entrybit", "events": ["access.granted", "access.denied"] }
```

`url` must be a public HTTPS address; it is checked now and again at every delivery. `events` must list what you want: there is no "everything". The response carries `signing_secret` **once**. At most ten endpoints, and the organization's plan must include webhooks. `GET /api/v1/org/webhooks` lists them (never their secrets); `DELETE /api/v1/org/webhooks/{id}` stops one.

Each delivery looks like this, and `data` is the same object `GET /api/v1/org/events` returns:

```http
POST <your url>
X-EntryBit-Event: access.granted
X-EntryBit-Event-Id: evt_5f0c…
X-EntryBit-Signature: t=1764576000,v1=<hex>

{ "id": "evt_5f0c…", "type": "access.granted", "created": 1764576000, "company_id": 3, "data": { "id": "rec_3kQ9…", "object": "access_event", "outcome": "granted" } }
```

To verify a delivery, compute HMAC-SHA256 of `<t>.<raw request body>` with the signing secret, compare it with `v1` in constant time, and refuse a `t` more than five minutes old.

Answer with any 2xx within ten seconds. Anything else is retried after 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours, then given up. A delivery can arrive twice and out of order, so de-duplicate on `data.id`. If you were down longer than the retries last, read what you missed from `GET /api/v1/org/events`.

## Scope summary

| Endpoint | Scope |
|---|---|
| `POST` / `PATCH` / `DELETE /api/v1/org/members…` | `org:members:write` |
| `GET /api/v1/org/members/{id}/credentials` and `…/delivery` | `org:credentials:read` |
| `POST` / `PATCH` / `DELETE …/credentials…` | `org:credentials:write` |
| `GET /api/v1/org/access-groups` | `org:access:read` |
| `POST` / `PATCH` / `DELETE /api/v1/org/access-groups…` | `org:access:write` |
| `POST` / `PATCH` / `DELETE /api/v1/org/facilities…` | `org:facilities:write` |
| `PATCH /api/v1/org/doors` | `org:doors:write` |
| `GET /api/v1/org/events` | `org:events:read` |
| `GET /api/v1/org/webhooks` | `org:webhooks:read` |
| `POST` / `DELETE /api/v1/org/webhooks…` | `org:webhooks:write` |