# Waitlist routes: admit, join

URL: /code/api/waitlist/verbs · Id: `page:code/api/waitlist/verbs`

> The Waitlist Verbs admit, join as api.sb routes, with inputs, result, refusals and an example.

Reference for [Waitlist](/business/nouns/waitlist), one group of [Waitlist routes](/code/api/waitlist).

### Waitlist.admit
Admit releases Leads from a Waitlist to the Offer they waited for, in the order the Waitlist ranks them. [Verb page](/business/nouns/waitlist/admit?interface=api).

```text
POST /{namespace}/waitlists/{waitlist}/admit
```

Path: `waitlist`. Body, as JSON: the other inputs. Emits [`Waitlist.admitted`](/business/events/Waitlist.admitted).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `waitlist` | [Waitlist](/business/nouns/waitlist) | Yes | The Waitlist. |
| `count` | `integer` | Yes | How many Leads to admit. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `leads` | list of [Lead](/business/nouns/lead) | Yes | The admitted Leads. |
| `waitlist` | [Waitlist](/business/nouns/waitlist) | Yes | The Waitlist after the admitted Leads left it. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |

**Example**

```bash
curl -X POST https://api.sb/leaseline.app/waitlists/waitlist_rBixb72HGB/admit \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"count":1}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "leads": [
    {
      "$id": "https://api.sb/leaseline.app/leads/lead_Kz1R9fhqzZ",
      "$type": "Lead",
      "status": "new"
    }
  ],
  "waitlist": {
    "$id": "https://api.sb/leaseline.app/waitlists/waitlist_rBixb72HGB",
    "$type": "Waitlist",
    "invited": 1,
    "rank": "signup"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Waitlist.admit",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### Waitlist.join
Join adds a Lead to a Waitlist for an Offer that is not open to them. [Verb page](/business/nouns/waitlist/join?interface=api).

```text
POST /{namespace}/waitlists/{waitlist}/join
```

Path: `waitlist`. Body, as JSON: the other inputs. Emits [`Waitlist.joined`](/business/events/Waitlist.joined).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `waitlist` | [Waitlist](/business/nouns/waitlist) | Yes | The Waitlist to join. |
| `email` | `email` | Yes | Where to reach the Lead. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `lead` | [Lead](/business/nouns/lead) | Yes | The waiting Lead. |
| `waitlist` | [Waitlist](/business/nouns/waitlist) | Yes | The Waitlist joined. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The input does not match the schema of the operation. | [`invalid-input`](/code/api/errors/invalid-input) | Read the schema of the operation, then send every required field with the right type. | None. |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |

**Example**

```bash
curl -X POST https://api.sb/leaseline.app/waitlists/waitlist_rBixb72HGB/join \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"email":"dana@leaseline.app"}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "lead": {
    "$id": "https://api.sb/leaseline.app/leads/lead_Kz1R9fhqzZ",
    "$type": "Lead",
    "status": "new"
  },
  "waitlist": {
    "$id": "https://api.sb/leaseline.app/waitlists/waitlist_rBixb72HGB",
    "$type": "Waitlist",
    "invited": 1,
    "rank": "signup"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Waitlist.join",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```