# Add a member

> Page: https://docs.flung.dev/reference/api/post-v1-members. Index of every page: https://docs.flung.dev/llms.txt

Lets a person, by email, sign in to Flung and connect apps to this workspace.

`POST /v1/members`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Add a member. |
| What does it need? | An API key or an OAuth access token. |
| What does it take? | A JSON body with the fields below. |
| What does it return? | Status 200 with a body of type [`Member`](https://docs.flung.dev/reference/api/schemas.md#member). |
| In the SDK? | `flung.members.add()` |
| What can go wrong? | `401` Missing, unknown, revoked or expired API key; `403` Only an owner, or an API key, may change members; `422` The request failed validation; `429` Too many requests for this credential; wait for `retry-after` seconds. Every failure has the same [error shape](https://docs.flung.dev/reference/api/errors.md). |

## What it does

Lets a person, by email, sign in to Flung and connect apps to this workspace. Adding an existing member changes their role.

## Example

**curl**

```bash
curl -X POST 'https://api.flung.dev/v1/members' \
  --header "Authorization: Bearer $FLUNG_API_KEY" \
  --header 'Content-Type: application/json' \
  --header "Idempotency-Key: $(uuidgen)" \
  --data '{
  "email": "sam@example.com"
}'
```

**TypeScript**

```ts
import { Flung } from '@flung.dev/sdk'

const flung = new Flung({ apiKey: process.env.FLUNG_API_KEY! })
const result = await flung.members.add({
  email: 'sam@example.com',
})
```

**fetch**

```js
const response = await fetch('https://api.flung.dev/v1/members', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.FLUNG_API_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': crypto.randomUUID(),
  },
  body: JSON.stringify({
    email: 'sam@example.com',
  }),
})
if (!response.ok) throw new Error((await response.json()).error.message)
const result = await response.json()
```

A successful answer looks like this:

```json
{
  "userId": "usr_aaaaaaaaaaaaaaaaaaaaaaaa",
  "email": "string",
  "role": "owner",
  "createdAt": "2026-11-01T09:00:00.000Z"
}
```

## Request body

The body has the type an object, with the fields below.

| Field | Type | Required | Description |
|---|---|---|---|
| `email` | `string` | yes | They sign in with this address; nothing is sent to it now. at most 254 characters. |
| `role` | `"owner" \| "member"` | no | `owner` may add and remove members; both may connect apps to the workspace. default "member". |

## Responses

| Status | Meaning | Body |
|---|---|---|
| 200 | The member. | [`Member`](https://docs.flung.dev/reference/api/schemas.md#member) |
| 401 | Missing, unknown, revoked or expired API key. | [`Error`](https://docs.flung.dev/reference/api/schemas.md#error) |
| 403 | Only an owner, or an API key, may change members. | [`Error`](https://docs.flung.dev/reference/api/schemas.md#error) |
| 422 | The request failed validation. | [`Error`](https://docs.flung.dev/reference/api/schemas.md#error) |
| 429 | Too many requests for this credential; wait for `retry-after` seconds. | [`Error`](https://docs.flung.dev/reference/api/schemas.md#error) |

## Response body

A 200 answer has the type [`Member`](https://docs.flung.dev/reference/api/schemas.md#member).

| Field | Type | Required | Description |
|---|---|---|---|
| `userId` | `string` | yes |  |
| `email` | `string` | yes |  |
| `role` | `"owner" \| "member"` | yes | `owner` may add and remove members; both may connect apps to the workspace. |
| `createdAt` | `string` | yes |  |

## See also

| Doc | Why |
|---|---|
| [API reference](https://docs.flung.dev/reference/api.md) | Every endpoint |
| [Schemas](https://docs.flung.dev/reference/api/schemas.md) | Every request and response type |
| [Errors](https://docs.flung.dev/reference/api/errors.md) | Every error code and what to do about it |
