> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developers.hive.co/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developers.hive.co/_mcp/server.

# Create or update contacts

POST https://api.hive.co/v2/contacts/
Content-Type: application/json

Push contact data to Hive. Contacts are matched by `email` or `phone_number`; re-sending the same identifier updates the existing contact rather than duplicating it.

Reference: https://developers.hive.co/api-reference/hive-api/contacts/create

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Headers

- `X-Partner-Id` (string, required) — Your OAuth application client ID.

### Body (application/json)

This endpoint expects a SaveContactsRequest.

- `contacts` (list of ContactToSaveRequest, required)

## Response

### 202

Received and queued for background processing. Not yet applied.

## Errors

### 422 Unprocessable Entity Error

Validation failed. For a batch write this is all-or-nothing. Field errors are keyed by resource name, then item index, then field path, query-parameter errors are keyed by parameter name, service-level rejections use a flat `errors` list.

- `map from string to any`

## Types

### ContactToSaveRequest

- `updated_at` (datetime, required)
- `email` (string, optional)
- `phone_number` (string, optional)
- `first_name` (string, optional)
- `last_name` (string, optional)
- `gender` (enum, optional)
  - Allowed values: `male`, `female`, `non_binary`, `unknown`
- `birthday` (datetime, optional)
- `address` (AddressRequest, optional)
- `is_email_opt_in` (boolean, optional)
- `is_sms_opt_in` (boolean, optional)
- `custom_properties` (map from string to string, optional)

### AddressRequest

- `address` (string, optional)
- `city` (string, optional)
- `state` (string, optional)
- `country` (string, optional)
- `zip` (string, optional)

## Examples

**Request**

```json
{
  "contacts": [
    {
      "updated_at": "2024-01-15T09:30:00Z"
    }
  ]
}
```

**Response**

```json
{}
```

**SDK Code**

```python
import requests

url = "https://api.hive.co/v2/contacts/"

payload = { "contacts": [{ "updated_at": "2024-01-15T09:30:00Z" }] }
headers = {
    "X-Partner-Id": "X-Partner-Id",
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://api.hive.co/v2/contacts/';
const options = {
  method: 'POST',
  headers: {
    'X-Partner-Id': 'X-Partner-Id',
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/json'
  },
  body: '{"contacts":[{"updated_at":"2024-01-15T09:30:00Z"}]}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

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

func main() {

	url := "https://api.hive.co/v2/contacts/"

	payload := strings.NewReader("{\n  \"contacts\": [\n    {\n      \"updated_at\": \"2024-01-15T09:30:00Z\"\n    }\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-Partner-Id", "X-Partner-Id")
	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.hive.co/v2/contacts/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Partner-Id"] = 'X-Partner-Id'
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"contacts\": [\n    {\n      \"updated_at\": \"2024-01-15T09:30:00Z\"\n    }\n  ]\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.hive.co/v2/contacts/")
  .header("X-Partner-Id", "X-Partner-Id")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"contacts\": [\n    {\n      \"updated_at\": \"2024-01-15T09:30:00Z\"\n    }\n  ]\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.hive.co/v2/contacts/', [
  'body' => '{
  "contacts": [
    {
      "updated_at": "2024-01-15T09:30:00Z"
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
    'X-Partner-Id' => 'X-Partner-Id',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.hive.co/v2/contacts/");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Partner-Id", "X-Partner-Id");
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"contacts\": [\n    {\n      \"updated_at\": \"2024-01-15T09:30:00Z\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-Partner-Id": "X-Partner-Id",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["contacts": [["updated_at": "2024-01-15T09:30:00Z"]]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.hive.co/v2/contacts/")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```