# Add a member

> Adds a person to an organization as a membership the API manages. A new email creates their BloomText user, owned by your account. They get an invite email only with send_invite_email: true. Only API keys change memberships the API made; people in BloomText see them locked as "Managed by API".

Source: https://www.bloomtext.com/developers/api/reference/create-member/

`POST /members`

Adds a person to an organization as a membership the API manages. A new email creates their BloomText user, owned by your account. They get an invite email only with `send_invite_email: true`. Only API keys change memberships the API made; people in BloomText see them locked as "Managed by API".

**Credentials:** [API key](https://www.bloomtext.com/developers/api/api-keys/) with member scopes · **Scope:** `members.write` · **Idempotent:** With `Idempotency-Key`

[Run in Postman](https://www.bloomtext.com/developers/api/postman/bloomtext-api.postman_collection.json): import the collection and set `api_key`.

### Query parameters

- `org_id` (UUID): The organization the call acts on, from List organizations. Required when an account API key reaches more than one organization; an organization key or a key limited to one organization can leave it out.

### Headers

- `Idempotency-Key` (UUID, required): A UUID you generate for each write. Retrying with the same key returns the original result for 24 hours. Reusing a key with a different method, path, or body returns 409.

### Body parameters

- `email` (string, required): The person's email address. A new one creates their BloomText user.

- `first_name` (string): 

- `last_name` (string): 

- `role` (admin, user): 

- `title` (string): 

- `send_invite_email` (boolean): Email them an invite to set a password, if they haven't signed in yet.

Any other field returns `422 unknown_field`. See [Unknown fields are rejected](https://www.bloomtext.com/developers/api/errors/#unknown-fields-are-rejected).

### Returns

Returns `201 Created` with the [Member object](https://www.bloomtext.com/developers/api/reference/member-object/).

### Errors

Failed requests return `application/problem+json` [problem details](https://www.bloomtext.com/developers/api/errors/). The errors specific to this endpoint:

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | `invalid_request` | The request is malformed, such as invalid JSON. |
| 400 | `org_id_required` | The key reaches more than one organization: pass `org_id`. |
| 401 | `invalid_token` | The API key is missing or malformed, or isn’t a BloomText key. |
| 401 | `key_revoked` | The API key was revoked. |
| 401 | `key_expired` | The API key’s expiry has passed. |
| 403 | `insufficient_scope` | The key doesn’t have the scope this endpoint needs. |
| 403 | `org_not_reachable` | The key can't reach the organization in `org_id`. |
| 403 | `accounts_not_enabled` | The account layer isn't turned on for this account yet. |
| 409 | `idempotency_key_reused` | The Idempotency-Key was already used with a different request. |
| 409 | `idempotency_request_in_progress` | A request with this Idempotency-Key is still running. Retry shortly. |
| 409 | `already_member` | That person is already a member of this organization. |
| 409 | `patient_account` | That email belongs to a patient's account. |
| 422 | `validation_failed` | A field failed validation. See `field_errors`. |
| 429 | `rate_limited` | Too many requests. Retry after `Retry-After` seconds. |

```bash filename="Request"
curl -X POST "https://api.bloomtext.com/v1/members" \
  -H "Authorization: Bearer $BLOOMTEXT_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

```js filename="Request"
const response = await fetch('https://api.bloomtext.com/v1/members', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.BLOOMTEXT_API_KEY}`,
    'Idempotency-Key': crypto.randomUUID(),
  },
})

if (!response.ok) throw new Error(`BloomText API error: ${response.status}`)
const data = await response.json()
```

```python filename="Request"
import os
import uuid

import requests

response = requests.post(
    "https://api.bloomtext.com/v1/members",
    headers={
        "Authorization": f"Bearer {os.environ['BLOOMTEXT_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
)
response.raise_for_status()
data = response.json()
```

```go filename="Request"
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"

	"github.com/google/uuid"
)

func main() {
	req, err := http.NewRequest("POST", "https://api.bloomtext.com/v1/members", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("BLOOMTEXT_API_KEY"))
	req.Header.Set("Idempotency-Key", uuid.NewString())

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, _ := io.ReadAll(res.Body)
	fmt.Println(res.Status, string(out))
}
```

```ruby filename="Request"
require "net/http"
require "json"
require "securerandom"

uri = URI("https://api.bloomtext.com/v1/members")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("BLOOMTEXT_API_KEY")}"
request["Idempotency-Key"] = SecureRandom.uuid

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end
data = JSON.parse(response.body)
```

```json filename="Response · 201 Created"
{
  "id": "8b9c2d2f-6b1a-44f4-a7b1-0d6d3f2d6f55",
  "org_id": "8b9c2d2f-6b1a-44f4-a7b1-0d6d3f2d6f55",
  "email": "string",
  "first_name": "string",
  "last_name": "string",
  "role": "admin",
  "account_role": "owner",
  "managed_by": "admin",
  "managed_by_name": "string"
}
```
