# Invite an address to sign up.

> Creates a Clerk invitation (Clerk emails the person a sign-up link to `KOIDOG_INVITE_REDIRECT_URL`) and marks the request invited on the koidog-site list.
> https://koi.dog/docs/api/invitations/send-invite/

`POST /api/v1/invites` · Scope: `approve`

An address that already has a pending or accepted invitation answers that one with `sent: false` and nothing is sent. A list that could not be marked answers `marked: false` and the reason; the invitation stands. Records `invite.sent` with who sent it. `422` for an address the koi.dog form would not take; `409 not_configured` and `502` as for the list. When an API key calls it, the timeline records who did what and the outcome. No path or query parameters.

## Headers.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Idempotency-Key` | `string` | no | Makes a retry safe: the same key with the same request returns the first answer and does nothing else. |

## Body.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `email` | `string` | yes | The address to invite. Clerk emails it a sign-up link; `422` for an address the koi.dog invite form would not take. 1 to 254 characters. |

## Response.

200 OK: a JSON object. The example has placeholder values.

- **422 validation_failed**: The body does not match its schema; each problem is in `details`.

## Request.

```sh
curl -X POST https://app.koi.dog/api/v1/invites \
    -H "Authorization: Bearer $KOIDOG_API_KEY" \
    -H "Idempotency-Key: $(uuidgen)" \
    -H "Content-Type: application/json" \
    -d '{
      "email": "<email>"
    }'
```

```js
const res = await fetch("https://app.koi.dog/api/v1/invites", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KOIDOG_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    email: "<email>",
  }),
});
console.log(await res.json());
```

```python
import os
import uuid

import requests

r = requests.post(
    "https://app.koi.dog/api/v1/invites",
    headers={
        "Authorization": f"Bearer {os.environ['KOIDOG_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "email": "<email>",
    },
)
r.raise_for_status()
print(r.json())
```

## Response example.

```json
{
  "invite": {
    "email": "string",
    "state": "requested",
    "requestedAt": "string",
    "requestState": "string",
    "invitation": { … }
  },
  "sent": false,
  "marked": false,
  "markError": "string"
}
```
