Add subscribers and endpoints
Send a customer's recorded people to Focus through the API, with their names and their phone numbers, email addresses or Teams user IDs, in one request.
Once a customer's account exists, Focus needs to know who is being recorded. That is two things:
Subscribers. The people in your customer's organisation, each with a name. See Subscribers.
Endpoints. The identities a person is recorded on: a phone number, an email address or a Microsoft Teams user ID. Each endpoint belongs to one person.
A recording is matched to a person through the endpoint it was made on. If an endpoint has no owner, its recordings cannot be shown against a person.
You can add subscribers by hand in the portal, on the People screen. This page covers doing it through the API, from your own provisioning system.
One request, or two#
You can send names and endpoints together, in a single request. POST /client/people.upsert takes a list of people, and each person carries their own list of endpoints. This is the recommended way.
There is also an endpoint-only call, POST /client/people/endpoint/upsert. It carries no name. Use it only when you need to register endpoints first and attach them to a person afterwards, by sending the person's ID.
| You have | Use |
|---|---|
| Names and endpoints together | people.upsert, once. |
| Endpoints now, names later | people/endpoint/upsert now, then people.upsert when you have the names. |
| A change to one person's endpoints | people.upsert again for that person, with their full list of endpoints. |
Before you start#
These calls are made as the customer's account, not as your parent account. Each account's people are its own.
When you created the account, the response gave you what you need to sign in to it:
| Value | Where it comes from |
|---|---|
clientId | clientId in the create-account response. |
apiKey | serviceUserApiKey in the create-account response. |
username | serviceUser |
Exchange them for a bearer token with POST /authWithApiKey, exactly as described in Getting Started:
curl -X POST "$BASE_URL/authWithApiKey" \
-H "Content-Type: application/json" \
-d '{
"clientId": 1234,
"apiKey": "<serviceUserApiKey>",
"username": "serviceUser"
}'Both calls on this page need the People.Update right, which the account's service user holds.
Send subscribers with their endpoints#
POST {{baseUrl}}/client/people.upsert
Creates each person if they are new and updates them if they already exist.
Request body#
The body is an object with one field, people, which is a list. Each person in the list has these fields:
| Field | Type | Required | Description |
|---|---|---|---|
fullName | string | Yes | The person's name, as it should appear in Focus. |
personType | string | Yes | staff for a subscriber. external for a contact, someone outside the organisation who is not recorded. |
thirdPartyId | string | No | Your own identifier for the person, for example their ID in your provisioning system. Send it every time. It is how Focus recognises the same person on later calls. |
email | string | No | The person's email address. |
endpoints | array | No | The person's endpoints. See How the endpoint list is applied. |
endpoints[].type | string | Yes | phone, email or teamsUserId. |
endpoints[].endpoint | string | Yes | The value: the phone number, the email address, or the Microsoft Teams user ID. |
isActive | boolean | No | Set to false for someone who has left. |
retentionGroupId | integer | No | The retention group to put the person in. Without it they use the account default. |
id | number | No | The Focus ID of an existing person, if you have stored it. |
A request must not contain the same thirdPartyId twice, or the same email twice. If it does, the whole request is rejected.
Example#
curl -X POST "$BASE_URL/client/people.upsert" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"people": [
{
"fullName": "Jane Smith",
"personType": "staff",
"thirdPartyId": "emp-00412",
"email": "jane.smith@example-customer.com",
"endpoints": [
{ "type": "phone", "endpoint": "447700900111" },
{ "type": "teamsUserId", "endpoint": "2c1f4a8e-7b3d-4e6a-9f10-5d2b8c7a6e41" }
]
},
{
"fullName": "Sam Patel",
"personType": "staff",
"thirdPartyId": "emp-00413",
"endpoints": [
{ "type": "phone", "endpoint": "447700900112" }
]
}
]
}'Response#
The response lists every person in the request under either completed or failed.
{
"completed": [
{
"id": 42,
"fullName": "Jane Smith",
"personType": "staff",
"thirdPartyId": "emp-00412",
"outcome": "inserted"
}
],
"failed": [
{
"person": { "fullName": "Sam Patel", "personType": "staff", "thirdPartyId": "emp-00413" },
"reason": "<why this person was not saved>"
}
]
}The example is shortened. Each completed person comes back with the details Focus now holds for them.
| Field | Description |
|---|---|
completed[].id | The person's Focus ID. Store it if you plan to use the endpoint-only call. |
completed[].outcome | inserted for a new person, updated for a changed one, unchanged if nothing was different. |
failed[].person | The person as you sent them. |
failed[].reason | Why they were not saved. |
People are saved one by one, so some can succeed while others fail. Always check failed, even on a 200.
| Status | When |
|---|---|
200 OK | At least one person was saved. |
400 Bad Request | Nobody was saved, or the body was not valid. |
401 Unauthorized | The bearer token is missing or has expired. |
403 Forbidden | The caller does not hold People.Update. |
How the endpoint list is applied#
The endpoints list is treated as the person's complete set of endpoints, not as additions.
| What you send | What happens |
|---|---|
| A list of endpoints | The person ends up owning exactly those endpoints. Any endpoint they owned before that is not in the list is taken away from them. |
An empty list, [] | The person loses all their endpoints. |
No endpoints field at all | The person's endpoints are left exactly as they are. |
So to add a second phone number to someone, send both numbers. To change only a person's name, leave endpoints out.
An endpoint that is taken away from a person is not deleted. It stays in the account with no owner.
Calling it again#
The call is safe to repeat. Send the same people again and they come back as unchanged.
Focus recognises an existing person by their id if you send it, otherwise by their thirdPartyId. This is why it is worth sending your own thirdPartyId from the start: you can then send your full list of people on every run, without first looking anyone up.
Endpoints that already have an owner affect how a person is matched:
If you send a person without an
id, and their endpoints already belong to one existing person, Focus treats your entry as that existing person and updates them.If you send a person with an
id, and their endpoints belong to a different person, that entry fails.If the endpoints you send for one person currently belong to two or more different people, that entry fails.
To move an endpoint from one person to another, take it off the old owner first, then add it to the new one.
Send endpoints on their own#
POST {{baseUrl}}/client/people/endpoint/upsert
Creates or updates endpoints without a name. The body is a list.
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | phone, email or teamsUserId. |
endpoint | string | Yes | The value. |
ownedByPersonId | integer | No | The Focus ID of the person who owns the endpoint. This is completed[].id from people.upsert. Leave it out for an endpoint that has no owner yet. |
isPrivate | boolean | No | Marks the endpoint as private. |
metadata | object | No | Your own reference data to store against the endpoint. |
curl -X POST "$BASE_URL/client/people/endpoint/upsert" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '[
{ "type": "phone", "endpoint": "447700900113" },
{ "type": "phone", "endpoint": "447700900114", "ownedByPersonId": 42 }
]'To give an unowned endpoint a name later, either send it again here with ownedByPersonId, or include it in the person's endpoints list in people.upsert.
Check what Focus holds#
To confirm what was saved, read it back with the search calls in the API reference:
For comparing Focus against your own system of record on a schedule, see People reconciliation.