> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.confirm.global/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.confirm.global/_mcp/server.

# Create or update a registry user

PUT https://api.confirm.global/partner/v1/users
Content-Type: application/json

Keeps registry user accounts in sync with yours, so a user's first
sign-in to CONFIRM is instant rather than provisioned on the spot.

**Also reactivates.** Sending a user you deactivated with
`DELETE /users/{external_user_ref}` brings back the same account
(`200`, `created: false`).

**Users in several registries.** Send the user once per registry, with
the same `external_user_ref` and a different `organization_ref`. Each
call adds that registry to the same account; nothing is moved, and a
single CareLink sign-in reaches every registry the user belongs to.
Signing in through a registry's link opens that registry; a user who
isn't a member of it is told they don't have access.
`DELETE /users/{external_user_ref}?organization_ref=` removes one
registry and leaves the others.

**Identity is keyed on your user ID.** Matching is by
`external_user_ref` first, then by email (case-insensitive). That
ordering is what makes an email or name change on your side *update* the
existing account — this endpoint can never produce a duplicate.

**Permissions are not synced.** Your system tells us who a user is and
which registry they belong to; what they can do inside CONFIRM is
governed by CONFIRM roles, managed in the portal. Role changes on your
side are deliberately ignored.

Reference: https://docs.confirm.global/partner-api/users/upsert-user

## Authentication

- `Authorization` header (bearer token, required) — Partner API key sent as `Authorization: Bearer cfk_...`. Keys are partner-level — one key reaches every registry linked to your partner account and nothing else. CONFIRM issues and revokes them; a key is shown exactly once at creation because only its hash is stored, and revocation takes effect on the next request. Develop against the sandbox base URL with a sandbox key, where telephony is restricted to an allowlist you provide.

## Request

### Body (application/json)

This endpoint expects an object.

- `external_user_ref` (string, required) — Your identifier for this user. The primary identity key.
- `organization_ref` (string, required) — A registry this user belongs to. Sending the same user for another registry adds that registry; it doesn't move them.
- `email` (string, required)
- `first_name` (string, optional)
- `last_name` (string, optional)

## Response

### 201

Account created. Sending an existing `external_user_ref` or email returns **200** and updates that account.

- `user_id` (string, required)
- `external_user_ref` (string, required) — Your user identifier, echoed back.
- `email` (string, required)
- `organization_ref` (string, optional)
- `created` (boolean, optional) — False when an existing account was updated instead.

## Errors

### 400 Bad Request Error

Invalid request (`error.type: invalid_request_error`, `code: invalid_request`) — missing or malformed fields. `details` lists each offending field.

- `error` (ErrorError, required)

### 401 Unauthorized Error

Missing, malformed, or revoked API key (`error.type: authentication_error`).

- `error` (ErrorError, required)

### 404 Not Found Error

Unknown `organization_ref`.

- `error` (ErrorError, required)

### 429 Too Many Requests Error

Rate limit exceeded (`error.type: rate_limit_error`). Design target: 600 requests/min per key, burst 100/10s. Honor the `Retry-After` header.

- `error` (ErrorError, required)

## Types

### ErrorError

- `type` (enum, required) — Broad error category.
  - Allowed values: `authentication_error`, `invalid_request_error`, `not_found_error`, `conflict_error`, `rate_limit_error`, `api_error`
- `code` (string, required) — Machine-readable error code, e.g. `invalid_request`, `unknown_location_ref` or `wrong_environment`. Branch on this; the strings are contract.
- `message` (string, required) — Human-readable explanation.
- `request_id` (string, required) — Identifier for this request — the same value as the response's `X-Request-Id` header. Include it when contacting CONFIRM support.
- `details` (list of ErrorErrorDetailsItems, optional) — Present on `invalid_request` (400): one entry per field that failed validation.
- `location_ref` (string, optional) — Present on `unknown_location_ref` (404) — the reference that wasn't found.
- `organization_ref` (string, optional) — Present on `unknown_organization_ref` (404) — the reference that wasn't found — and on `email_has_account` (409) — the registry the invitation was for.
- `external_ref` (string, optional) — Present on workspace-teardown refusals (403) — the workspace you asked to delete — and on applicant errors (`unknown_candidate_ref`, `no_application_at_location`, `outcome_conflict`) — the applicant ref.
- `organization_refs` (list of string, optional) — Present on `ambiguous_location_ref` (409) — the registries the ref exists in.
- `locations` (list of ErrorErrorLocationsItems, optional) — Present on `location_refs_span_organizations` (400) — each ref you sent with the registry it belongs to.

### ErrorErrorDetailsItems

- `field` (string, required) — Dotted path to the offending field, e.g. `address.postal_code`.
- `message` (string, required) — Why that field was rejected.

### ErrorErrorLocationsItems

- `location_ref` (string, optional)
- `organization_ref` (string, optional, nullable)

## Examples

**Request**

```json
{
  "external_user_ref": "cl_user_5512",
  "organization_ref": "cl_biz_4471",
  "email": "jeff@suncoastnurses.com"
}
```

**Response**

```json
{
  "user_id": "string",
  "external_user_ref": "cl_user_5512",
  "email": "string",
  "organization_ref": "cl_biz_4471",
  "created": true
}
```

**SDK Code**

```python
import requests

url = "https://api.confirm.global/partner/v1/users"

payload = {
    "external_user_ref": "cl_user_5512",
    "organization_ref": "cl_biz_4471",
    "email": "jeff@suncoastnurses.com"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.confirm.global/partner/v1/users';
const options = {
  method: 'PUT',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"external_user_ref":"cl_user_5512","organization_ref":"cl_biz_4471","email":"jeff@suncoastnurses.com"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.confirm.global/partner/v1/users"

	payload := strings.NewReader("{\n  \"external_user_ref\": \"cl_user_5512\",\n  \"organization_ref\": \"cl_biz_4471\",\n  \"email\": \"jeff@suncoastnurses.com\"\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.confirm.global/partner/v1/users")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"external_user_ref\": \"cl_user_5512\",\n  \"organization_ref\": \"cl_biz_4471\",\n  \"email\": \"jeff@suncoastnurses.com\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api.confirm.global/partner/v1/users")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"external_user_ref\": \"cl_user_5512\",\n  \"organization_ref\": \"cl_biz_4471\",\n  \"email\": \"jeff@suncoastnurses.com\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api.confirm.global/partner/v1/users', [
  'body' => '{
  "external_user_ref": "cl_user_5512",
  "organization_ref": "cl_biz_4471",
  "email": "jeff@suncoastnurses.com"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.confirm.global/partner/v1/users");
var request = new RestRequest(Method.PUT);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"external_user_ref\": \"cl_user_5512\",\n  \"organization_ref\": \"cl_biz_4471\",\n  \"email\": \"jeff@suncoastnurses.com\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "external_user_ref": "cl_user_5512",
  "organization_ref": "cl_biz_4471",
  "email": "jeff@suncoastnurses.com"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.confirm.global/partner/v1/users")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```