# Create a profile

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

A profile keeps one of your customers' accounts apart from the rest of the workspace.

`POST /v1/profiles`

## TL;DR

| Question | Answer |
|---|---|
| What does it do? | Create a profile. |
| What does it need? | An API key or an OAuth access token. |
| What does it take? | A JSON body with the fields below, and `idempotency-key` in a header. |
| What does it return? | Status 201 with a body of type [`Profile`](https://docs.flung.dev/reference/api/schemas.md#profile). |
| In the SDK? | `flung.profiles.create()` |
| As an MCP tool? | [`create_profile`](https://docs.flung.dev/mcp/tools/create-profile.md) |
| What can go wrong? | `401` Missing, unknown, revoked or expired API key; `409` Another profile already has this external id; `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

A profile keeps one of your customers' accounts apart from the rest of the workspace. Make a connect token with its `profileId`, and the accounts that customer connects join it; list them with `GET /v1/accounts?profileId=`.

## Example

**curl**

```bash
curl -X POST 'https://api.flung.dev/v1/profiles' \
  --header "Authorization: Bearer $FLUNG_API_KEY" \
  --header 'Content-Type: application/json' \
  --header "Idempotency-Key: $(uuidgen)" \
  --data '{
  "name": "Acme Studio",
  "externalId": "user_8412"
}'
```

**TypeScript**

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

const flung = new Flung({ apiKey: process.env.FLUNG_API_KEY! })
const result = await flung.profiles.create({
  name: 'Acme Studio',
  externalId: 'user_8412',
})
```

**fetch**

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

A successful answer looks like this:

```json
{
  "id": "prof_aaaaaaaaaaaaaaaaaaaaaaaa",
  "name": "string",
  "externalId": "string",
  "createdAt": "2026-11-01T09:00:00.000Z",
  "updatedAt": "2026-11-01T09:00:00.000Z"
}
```

## Header parameters

| Field | Type | Required | Description |
|---|---|---|---|
| `idempotency-key` | `string` | no | Any unique string, such as a UUID. A retry with the same key and body within 24 hours gets the first answer instead of running again. |

## Request body

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

| Field | Type | Required | Description |
|---|---|---|---|
| `name` | `string` | yes | A name for people to read, such as your customer's name. Letters and digits of every script, spaces, and - _ . ' & ( ) +. No emoji, other symbols or invisible characters. Runs of spaces become one and the ends are trimmed. It must hold a letter or a digit, and may not be profane. at least 1 character; at most 200 characters. |
| `externalId` | `string` | no | Your own id for this customer, such as their user id. Unique in the workspace, so you can find the profile again by it. at least 1 character; at most 255 characters. |

## Responses

| Status | Meaning | Body |
|---|---|---|
| 201 | The profile. | [`Profile`](https://docs.flung.dev/reference/api/schemas.md#profile) |
| 401 | Missing, unknown, revoked or expired API key. | [`Error`](https://docs.flung.dev/reference/api/schemas.md#error) |
| 409 | Another profile already has this external id. | [`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 201 answer has the type [`Profile`](https://docs.flung.dev/reference/api/schemas.md#profile).

| Field | Type | Required | Description |
|---|---|---|---|
| `id` | `string` | yes |  |
| `name` | `string` | yes |  |
| `externalId` | `string \| null` | yes |  |
| `createdAt` | `string` | yes |  |
| `updatedAt` | `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 |
| [`create_profile`](https://docs.flung.dev/mcp/tools/create-profile.md) | The same operation as an MCP tool |
