# Accept an invitation

`POST /v1/invitations/accept`

The signed-in user's email must match the invitation.

## Authentication

A session token: `Authorization: Bearer <session token>`, or the session cookie in the browser.

## Request body

`application/json`

```json
{
  "additionalProperties": false,
  "properties": {
    "token": {
      "maxLength": 128,
      "minLength": 1,
      "type": "string"
    }
  },
  "required": [
    "token"
  ],
  "type": "object"
}
```

## Responses

### 201

The membership the invitation created.

`application/json`

```json
{
  "additionalProperties": false,
  "description": "The membership the invitation created.",
  "properties": {
    "member_id": {
      "pattern": "^mem_[0-7][0-9a-hjkmnp-tv-z]{25}$",
      "type": "string"
    },
    "org_id": {
      "pattern": "^org_[0-7][0-9a-hjkmnp-tv-z]{25}$",
      "type": "string"
    },
    "role": {
      "anyOf": [
        {
          "enum": [
            "owner"
          ],
          "type": "string"
        },
        {
          "enum": [
            "admin"
          ],
          "type": "string"
        },
        {
          "enum": [
            "member"
          ],
          "type": "string"
        }
      ]
    }
  },
  "required": [
    "org_id",
    "member_id",
    "role"
  ],
  "type": "object"
}
```

### 401

unauthorized: no valid session, or the email is not verified.

Problem type: [unauthorized](https://docs.dlogify.com/errors/unauthorized.md).

### 403

csrf-origin-rejected: a cookie-authenticated change from an origin outside the web app.

Problem type: [csrf-origin-rejected](https://docs.dlogify.com/errors/csrf-origin-rejected.md).

### 404

not-found: the token is unknown, expired, already used, or for another email address.

Problem type: [not-found](https://docs.dlogify.com/errors/not-found.md).

### 409

conflict: the user is already a member of the organization.

Problem type: [conflict](https://docs.dlogify.com/errors/conflict.md).

### 422

validation-failed: the request does not match the schema.

Problem type: [validation-failed](https://docs.dlogify.com/errors/validation-failed.md).

### 429

rate-limited: per-user management request limit.

Problem type: [rate-limited](https://docs.dlogify.com/errors/rate-limited.md).

## Example

```bash
curl -X POST "https://api.dlogify.com/v1/invitations/accept" \
  -H "Authorization: Bearer $DLOGIFY_SESSION" \
  -H "Content-Type: application/json" \
  --data-binary @body
```

Source: https://docs.dlogify.com/api/invitations/acceptInvitation
