# POST /contacts — Create Contacts

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

Hit the API with POST method and fill the following data according your requirements to create multiple contacts. Query Params:

**Body parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| onDuplicate | string | No | OnDuplicate field determines whether to skip (default) or overwrite an existing contact |
| mobile | string | Yes | Phone number with the dialing code |
| name | string | No | Full name of the contact |
| optin | string | No | Indicates if the contact has opted in (true or false) |
| incomingBlocked | string | No | Specifies if messages are blocked for this contact |
| tags | string | No | List of tags to assign to the contact. Ensure these tags exist in Settings |
| 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 ignored |

**Example request body:**

```json
[
    {
        "mobile": "9179897xxxxx",
        "name": "Alex cron",
        "optin": true,
        "incomingBlocked": false,
        "tags": [
            "indian",
            "vegetarian",
            "engineer"
        ],
        "attributes": [
            {
                "name": "city",
                "value": "bhopal"
            }
        ]
    }
]
```

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

```json
{
    "status": "success",
    "message": "1 contact saved successfully",
    "data": {
        "createdContacts": [
            {
                "mobile": "917697xxxxx",
                "name": "Alex cron",
                "optin": true,
                "incomingBlocked": false,
                "tags": [
                    "indian",
                    "vegetarian",
                    "engineer"
                ],
                "attributes": [
                    {
                        "name": "city",
                        "value": "bhopal"
                    }
                ],
                "source": "api",
                "list": [
                    "all",
                    "sups"
                ]
            }
        ],
        "failedCount": 0,
        "failedContacts": []
    }
}
```

**Code examples:**

_cURL_

```curl
curl -X POST https://chatflow.pabbly.com/api/v1/contacts \
  -H "Authorization: Bearer {{YOUR_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{
    "mobile": "{{mobile}}"
  }'
```

_Ruby_

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

uri = URI('https://chatflow.pabbly.com/api/v1/contacts')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer {{YOUR_API_KEY}}'
request['Content-Type'] = 'application/json'
request.body = "{\"mobile\":\"{{mobile}}\"}"

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.post(
    'https://chatflow.pabbly.com/api/v1/contacts',
    headers={'Authorization': 'Bearer {{YOUR_API_KEY}}'},
    json={
    'mobile': '{{mobile}}'
},
)

data = response.json()
```

_PHP_

```php
<?php
$ch = curl_init('https://chatflow.pabbly.com/api/v1/contacts');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer {{YOUR_API_KEY}}', 'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"mobile":"{{mobile}}"}');

$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"))
    .header("Authorization", "Bearer {{YOUR_API_KEY}}")
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("{\"mobile\":\"{{mobile}}\"}"));

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', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer {{YOUR_API_KEY}}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "mobile": "{{mobile}}"
  }),
});

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

_Go_

```go
package main

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

func main() {
    payload := strings.NewReader("{\"mobile\":\"{{mobile}}\"}")
    req, _ := http.NewRequest("POST", "https://chatflow.pabbly.com/api/v1/contacts", 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.Post, "https://chatflow.pabbly.com/api/v1/contacts");
request.Headers.TryAddWithoutValidation("Authorization", "Bearer {{YOUR_API_KEY}}");
request.Content = new StringContent("{\"mobile\":\"{{mobile}}\"}");
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:**

- [PUT /contacts/{{id}} — Update Contact](/chatflow/contacts/update-contact)
- [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)

