# Import patients

> Starts importing up to 10,000 patients in the background. Send JSON, or CSV with Content-Type text/csv and the columns first_name, last_name, dob, mrn, phone, email. Each row is matched like Create a patient.

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

`POST /patient-imports`

Starts importing up to 10,000 patients in the background. Send JSON, or CSV with `Content-Type text/csv` and the columns first_name, last_name, dob, mrn, phone, email. Each row is matched like Create a patient.

**Credentials:** [API key](https://www.bloomtext.com/developers/api/api-keys/) or an [org admin’s OAuth token](https://www.bloomtext.com/developers/api/oauth/) · **Scope:** `patients.write` · **Idempotent:** With `Idempotency-Key`

### 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

Patients to import. To send CSV instead, use `Content-Type: text/csv`.

- `patients` (array of PatientCreate, required): Up to 10,000 patients.

  Child attributes:
- `first_name` (string): First name.

- `last_name` (string): Last name.

- `date_of_birth` (date): Date of birth.

- `phone` (string): Mobile number. Any common format; BloomText stores it as E.164.

- `email` (string): Email address.

- `mrn` (string): The patient's ID in your system. Matched first.

### Returns

Returns `202 Accepted` with the [Patient import object](https://www.bloomtext.com/developers/api/reference/patient-import-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. |
| 401 | `invalid_token` | The API key or access token is missing, expired, or revoked. |
| 403 | `insufficient_scope` | The credential doesn’t have the scope this endpoint needs. |
| 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. |
| 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/patient-imports" \
  -H "Authorization: Bearer $BLOOMTEXT_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"patients":[{"first_name":"Jane","last_name":"Doe","date_of_birth":"1986-04-12","phone":"(512) 555-0143","mrn":"MRN-20931"},{"first_name":"John","last_name":"Doe","phone":"512-555-0188","mrn":"MRN-20932"}]}'
```

```js filename="Request"
const response = await fetch('https://api.bloomtext.com/v1/patient-imports', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.BLOOMTEXT_API_KEY}`,
    'Idempotency-Key': crypto.randomUUID(),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({"patients":[{"first_name":"Jane","last_name":"Doe","date_of_birth":"1986-04-12","phone":"(512) 555-0143","mrn":"MRN-20931"},{"first_name":"John","last_name":"Doe","phone":"512-555-0188","mrn":"MRN-20932"}]}),
})

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/patient-imports",
    headers={
        "Authorization": f"Bearer {os.environ['BLOOMTEXT_API_KEY']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={"patients":[{"first_name":"Jane","last_name":"Doe","date_of_birth":"1986-04-12","phone":"(512) 555-0143","mrn":"MRN-20931"},{"first_name":"John","last_name":"Doe","phone":"512-555-0188","mrn":"MRN-20932"}]},
)
response.raise_for_status()
data = response.json()
```

```go filename="Request"
package main

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

	"github.com/google/uuid"
)

func main() {
	body := bytes.NewBufferString(`{"patients":[{"first_name":"Jane","last_name":"Doe","date_of_birth":"1986-04-12","phone":"(512) 555-0143","mrn":"MRN-20931"},{"first_name":"John","last_name":"Doe","phone":"512-555-0188","mrn":"MRN-20932"}]}`)
	req, err := http.NewRequest("POST", "https://api.bloomtext.com/v1/patient-imports", body)
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("BLOOMTEXT_API_KEY"))
	req.Header.Set("Idempotency-Key", uuid.NewString())
	req.Header.Set("Content-Type", "application/json")

	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/patient-imports")
request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch("BLOOMTEXT_API_KEY")}"
request["Idempotency-Key"] = SecureRandom.uuid
request["Content-Type"] = "application/json"
request.body = { patients: [{"first_name":"Jane","last_name":"Doe","date_of_birth":"1986-04-12","phone":"(512) 555-0143","mrn":"MRN-20931"},{"first_name":"John","last_name":"Doe","phone":"512-555-0188","mrn":"MRN-20932"}] }.to_json

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 · 202 Accepted"
{
  "id": "imp_71c2",
  "status": "running",
  "rows": 2,
  "created": 0,
  "matched": 0,
  "failed": 0,
  "results": null,
  "created_at": "2026-09-21T15:04:05Z"
}
```
