---
title: "Assign users to a contact"
description: "Assigns one or more team members to a contact, identified by their\nlogin phone numbers. If the contact does not exist yet it is created.\n"
---

> Documentation Index
> Fetch the complete documentation index at: https://zacx.io/llms.txt
> Use this file to discover all available pages before exploring further.

Path: Zacx Public API › Contacts

`POST /users/assign`

Assigns one or more team members to a contact, identified by their
login phone numbers. If the contact does not exist yet it is created.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Request body

- `assignContactUsers.phoneNumber` (string, required) — The contact's phone number with country code.
  - example `"919999999990"`
- `assignContactUsers.users` (array<string>, required) — Login phone numbers of the team members.
  - example `["919100110151"]`

## Example request

```json
{
  "phoneNumber": "919999999990",
  "users": [
    "919100110151"
  ]
}
```

## Code samples

### cURL

```curl
curl --request POST \
  --url https://api.zacx.io/v1/users/assign \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "phoneNumber": "919999999990",
  "users": [
    "919100110151"
  ]
}
'
```

### TypeScript

```typescript
const url = 'https://api.zacx.io/v1/users/assign';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({phoneNumber: '919999999990', users: ['919100110151']})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.zacx.io/v1/users/assign"

payload = {
    "phoneNumber": "919999999990",
    "users": ["919100110151"]
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

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

print(response.text)
```

## Responses

### 200

The assignment was processed.

#### Example

```json
{
  "status": "success",
  "message": "User successfully added to the contact"
}
```

- `assignContactUsers.response.200.status` (string, required)
- `assignContactUsers.response.200.message` (string, required)
- `assignContactUsers.response.200.code` (string, optional) — Present when the call succeeded but changed nothing, for example `TAG_ALREADY_ASSOCIATED`.

### 404

The user does not exist in this workspace.

#### Example

```json
{
  "status": "error",
  "code": "USER_NOT_FOUND",
  "message": "User not found in workspace"
}
```

- `assignContactUsers.response.404.status` (string, required)
- `assignContactUsers.response.404.code` (string, required) — Stable machine-readable error code.
- `assignContactUsers.response.404.message` (string, required) — Human-readable explanation.


Source: https://zacx.io/api/contact/assign-users/index.md
