# PUT /contacts/{{id}} — Update Contact

> Product: **Pabbly Chatflow** (v1)
> Base URL: `https://chatflow.pabbly.com/api/v1`
> Auth: Bearer via `Authorization` header
> Canonical: `/chatflow/contacts/update-contact`

Hit the API with PUT method and fill the following data according your requirements to update a contact. Path Variables (URL Params):

**Path parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| id | string | Yes | 24-character Hexadecimal id to identify and update the specific contact |

**Body parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| mobile | string | No | Phone number with the dialing code. |
| name | string | No | Full name of the contact. |
| optin | boolean | No | Indicates if the contact has opted in (true or false). |
| incomingBlocked | boolean | No | Specifies if messages are blocked for this contact (true or false). |
| tags | array | No | List of tags to assign to the contact. Ensure these tags exist in Settings. Note: Whatever data you send in the tags field will replace all existing tags in your contact. |
| attributes | string | No | "attributes" field refers to Custom Fields on the Contact. Key-value pairs for custom attributes. Attributes must exist in Settings. Use name and value keys inside the object. If the value is empty then attribute will removed |
| tagsToAdd | string | No | Tags you want to add. Tags must exist in Settings. |
| tagsToRemove | string | No | Tags you want to remove |

**Example request body:**

```json
{
    "mobile": "917989xxxxx",
    "name": "Alex cron",
    "optin": true,
    "incomingBlocked": false,
    "tags": [
        "swedish",
        "non-vegetarian",
        "architect"
    ]
}
```

**Response (200)** — Success Response:

```json
{
    "status": "success",
    "message": "Contact updated successfully",
    "data": {
        "_id": "67ab34b8251203ad797ee76f",
        "name": "Alex cron",
        "countryCode": "91",
        "mobile": "917989xxxxx",
        "status": "active",
        "source": "api",
        "optin": true,
        "attributes": [
            {
                "name": "city",
                "value": "las vegas",
                "_id": "67ab3557251203ad797ee529"
            }
        ],
        "incomingBlocked": false,
        "list": [
            "all",
            "sups"
        ],
        "tags": [
            "swedish",
            "non-vegetarian",
            "architect"
        ],
        "__v": 1,
        "createdAt": "2025-02-11T11:30:00.894Z",
        "updatedAt": "2025-02-11T11:32:39.589Z"
    }
}
```

**Code examples:**

_cURL_

```curl
curl -X PUT https://chatflow.pabbly.com/api/v1/contacts/{{id}} \
  -H "Authorization: Bearer {{YOUR_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{
    "mobile": "917989xxxxx",
    "name": "Alex cron",
    "optin": true,
    "incomingBlocked": false,
    "tags": [
      "swedish",
      "non-vegetarian",
      "architect"
    ]
  }'
```

_Ruby_

```ruby
require 'net/http'
require 'json'

uri = URI('https://chatflow.pabbly.com/api/v1/contacts/{{id}}')
request = Net::HTTP::Put.new(uri)
request['Authorization'] = 'Bearer {{YOUR_API_KEY}}'
request['Content-Type'] = 'application/json'
request.body = "{\"mobile\":\"917989xxxxx\",\"name\":\"Alex cron\",\"optin\":true,\"incomingBlocked\":false,\"tags\":[\"swedish\",\"non-vegetarian\",\"architect\"]}"

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
  http.request(request)
end

data = JSON.parse(response.body)
```

_Python_

```python
import requests

response = requests.put(
    'https://chatflow.pabbly.com/api/v1/contacts/{{id}}',
    headers={'Authorization': 'Bearer {{YOUR_API_KEY}}'},
    json={
    'mobile': '917989xxxxx',
    'name': 'Alex cron',
    'optin': True,
    'incomingBlocked': False,
    'tags': [
        'swedish',
        'non-vegetarian',
        'architect'
    ]
},
)

data = response.json()
```

_PHP_

```php
<?php
$ch = curl_init('https://chatflow.pabbly.com/api/v1/contacts/{{id}}');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer {{YOUR_API_KEY}}', 'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"mobile":"917989xxxxx","name":"Alex cron","optin":true,"incomingBlocked":false,"tags":["swedish","non-vegetarian","architect"]}');

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
```

_Java_

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
HttpRequest.Builder builder = HttpRequest.newBuilder()
    .uri(URI.create("https://chatflow.pabbly.com/api/v1/contacts/{{id}}"))
    .header("Authorization", "Bearer {{YOUR_API_KEY}}")
    .header("Content-Type", "application/json")
    .PUT(HttpRequest.BodyPublishers.ofString("{\"mobile\":\"917989xxxxx\",\"name\":\"Alex cron\",\"optin\":true,\"incomingBlocked\":false,\"tags\":[\"swedish\",\"non-vegetarian\",\"architect\"]}"));

HttpRequest request = builder.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

_Node.js_

```node
const response = await fetch('https://chatflow.pabbly.com/api/v1/contacts/{{id}}', {
  method: 'PUT',
  headers: {
    'Authorization': 'Bearer {{YOUR_API_KEY}}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "mobile": "917989xxxxx",
    "name": "Alex cron",
    "optin": true,
    "incomingBlocked": false,
    "tags": [
      "swedish",
      "non-vegetarian",
      "architect"
    ]
  }),
});

const data = await response.json();
```

_Go_

```go
package main

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

func main() {
    payload := strings.NewReader("{\"mobile\":\"917989xxxxx\",\"name\":\"Alex cron\",\"optin\":true,\"incomingBlocked\":false,\"tags\":[\"swedish\",\"non-vegetarian\",\"architect\"]}")
    req, _ := http.NewRequest("PUT", "https://chatflow.pabbly.com/api/v1/contacts/{{id}}", payload)
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Bearer {{YOUR_API_KEY}}")

    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)
    fmt.Println(string(body))
}
```

_.NET_

```dotnet
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Put, "https://chatflow.pabbly.com/api/v1/contacts/{{id}}");
request.Headers.TryAddWithoutValidation("Authorization", "Bearer {{YOUR_API_KEY}}");
request.Content = new StringContent("{\"mobile\":\"917989xxxxx\",\"name\":\"Alex cron\",\"optin\":true,\"incomingBlocked\":false,\"tags\":[\"swedish\",\"non-vegetarian\",\"architect\"]}");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

var response = await client.SendAsync(request);
var data = await response.Content.ReadAsStringAsync();
Console.WriteLine(data);
```

---

**Other endpoints in Contacts:**

- [POST /contacts — Create Contacts](/chatflow/contacts/create-contacts)
- [GET /contacts/ — Get Contacts](/chatflow/contacts/get-contacts)
- [GET /contacts/{{id}} — Get Contact by Id](/chatflow/contacts/get-contact-by-id)
- [GET /contacts/lists — Get Contact-lists](/chatflow/contacts/get-contact-lists)

