---
title: "Upsert contact"
url: https://docs.gleap.ai/en/reference/conversations-api/upsert
method: PUT
path: "/s2s/contacts/{userId}"
api: "Conversations API"
tag: "S2S Contacts"
operationId: "Upsert"
updatedAt: "2026-11-01T18:40:16.191Z"
language: en
---

# Upsert contact

`PUT https://api.gleap.io/v3/s2s/contacts/{userId}`

Create or update a contact. Returns the full contact including its unread conversation count.

## Authorization

- `Authorization` (header, required): `Bearer <token>`

## Path parameters

- `userId` (string, required)

## Headers

- `Gleap-Version` (string): Pin a specific API version; defaults to the current version.

## Request body (`application/json`, required)

- `name` (string)
- `email` (string)
- `phone` (string)
- `language` (string): ISO language code, e.g. "en", "az".
- `companyId` (string)
- `companyName` (string)
- `plan` (string)
- `value` (number<double>)
- `customData` (any): Arbitrary custom contact data (flat key→value object).

## Example request

```bash
curl --request PUT \
  --url 'https://api.gleap.io/v3/s2s/contacts/{userId}' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "name": "<name>",
  "email": "<email>",
  "phone": "<phone>",
  "language": "<language>"
}'
```

## Responses

### 200 (`application/json`)

Ok

- `userId` (string, required)
- `name` (string)
- `email` (string)
- `phone` (string)
- `language` (string)
- `companyId` (string)
- `companyName` (string)
- `plan` (string)
- `value` (number<double>)
- `customData` (object): Construct a type with a set of properties K of type T
- `unread` (number<double>)
- `createdAt` (string<date-time>)
- `lastActivityAt` (string<date-time>)

```json
{
  "userId": "string",
  "name": "string",
  "email": "string",
  "phone": "string",
  "language": "string",
  "companyId": "string",
  "companyName": "string",
  "plan": "string",
  "value": 0,
  "customData": {},
  "unread": 0,
  "createdAt": "2026-01-01T12:00:00Z",
  "lastActivityAt": "2026-01-01T12:00:00Z"
}
```

### 401 (`application/problem+json`)

Missing, invalid or revoked service account token.

- `type` (string, required)
- `title` (string, required)
- `status` (number, required)
- `code` (string, required)
- `detail` (string)
- `request_id` (string)

```json
{
  "type": "https://docs.gleap.io/s2s/problems/conversation_closed",
  "title": "string",
  "status": 0,
  "code": "conversation_closed",
  "detail": "string",
  "request_id": "req_66c0ffee0000000000000001"
}
```

### 404 (`application/problem+json`)

The addressed resource does not exist in this project.

- `type` (string, required)
- `title` (string, required)
- `status` (number, required)
- `code` (string, required)
- `detail` (string)
- `request_id` (string)

```json
{
  "type": "https://docs.gleap.io/s2s/problems/conversation_closed",
  "title": "string",
  "status": 0,
  "code": "conversation_closed",
  "detail": "string",
  "request_id": "req_66c0ffee0000000000000001"
}
```

### 422 (`application/problem+json`)

Idempotency-Key reuse with a different request body.

- `type` (string, required)
- `title` (string, required)
- `status` (number, required)
- `code` (string, required)
- `detail` (string)
- `request_id` (string)

```json
{
  "type": "https://docs.gleap.io/s2s/problems/conversation_closed",
  "title": "string",
  "status": 0,
  "code": "conversation_closed",
  "detail": "string",
  "request_id": "req_66c0ffee0000000000000001"
}
```

### 429 (`application/problem+json`)

Rate limit exceeded — honor the Retry-After header.

- `type` (string, required)
- `title` (string, required)
- `status` (number, required)
- `code` (string, required)
- `detail` (string)
- `request_id` (string)

```json
{
  "type": "https://docs.gleap.io/s2s/problems/conversation_closed",
  "title": "string",
  "status": 0,
  "code": "conversation_closed",
  "detail": "string",
  "request_id": "req_66c0ffee0000000000000001"
}
```

### default (`application/problem+json`)

Any other error, including validation\_failed (400) and internal\_error (500).

- `type` (string, required)
- `title` (string, required)
- `status` (number, required)
- `code` (string, required)
- `detail` (string)
- `request_id` (string)

```json
{
  "type": "https://docs.gleap.io/s2s/problems/conversation_closed",
  "title": "string",
  "status": 0,
  "code": "conversation_closed",
  "detail": "string",
  "request_id": "req_66c0ffee0000000000000001"
}
```
