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

# Create User Custom Field

POST https://www.crehana.com/api/v5/rest/org/{organization_slug}/users/{centralized_user_id}/custom-fields/
Content-Type: application/json

Assign values for one or more custom fields to the user. Fields not
included in the request keep their current value.

Reference: https://developer.crehana.com/api-reference/endpoints/users/create-user-custom-field

## Authentication

- `Api-Key` header (required) — API key of the organization. Always sent together with the `Secret-Access` header.

## Servers

- `https://www.crehana.com` (Production, default)
- `https://qa.creha.co` (QA)

## Request

### Path parameters

- `organization_slug` (string, required)
- `centralized_user_id` (integer, required)

### Body (application/json)

This endpoint expects a CreateUserCustomFieldInput.

- `custom_fields` (list of CustomFieldValue, required) — List of custom fields

## Response

### 200

Successful Response

- `message` (string, required) — Message of the response

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### CustomFieldValue

- `id` (integer, required) — Id of the custom field
- `type` (enum, required) — Type of the custom field
  - Allowed values: `MULTIPLE`, `NUMBER`, `TEXT`, `DATE`
- `value` (string, optional) — Value of the custom field, only valid for custom field of type TEXT, DATE and NUMBER
- `choice_id` (integer, optional) — Id of the choice selected for the custom field, only valid for custom field of type CHOICE

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### ValidationErrorLocItems

## Examples

**Request**

```json
{
  "custom_fields": [
    {
      "id": 1,
      "type": "MULTIPLE"
    }
  ]
}
```

**Response**

```json
{
  "message": "string"
}
```

**SDK Code**

```python
import requests

url = "https://www.crehana.com/api/v5/rest/org/organization_slug/users/1/custom-fields/"

payload = { "custom_fields": [
        {
            "id": 1,
            "type": "MULTIPLE"
        }
    ] }
headers = {
    "Secret-Access": "Secret-Access",
    "Api-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript
const url = 'https://www.crehana.com/api/v5/rest/org/organization_slug/users/1/custom-fields/';
const options = {
  method: 'POST',
  headers: {
    'Secret-Access': 'Secret-Access',
    'Api-Key': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"custom_fields":[{"id":1,"type":"MULTIPLE"}]}'
};

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://www.crehana.com/api/v5/rest/org/organization_slug/users/1/custom-fields/"

	payload := strings.NewReader("{\n  \"custom_fields\": [\n    {\n      \"id\": 1,\n      \"type\": \"MULTIPLE\"\n    }\n  ]\n}")

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

	req.Header.Add("Secret-Access", "Secret-Access")
	req.Header.Add("Api-Key", "<apiKey>")
	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://www.crehana.com/api/v5/rest/org/organization_slug/users/1/custom-fields/")

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

request = Net::HTTP::Post.new(url)
request["Secret-Access"] = 'Secret-Access'
request["Api-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"custom_fields\": [\n    {\n      \"id\": 1,\n      \"type\": \"MULTIPLE\"\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://www.crehana.com/api/v5/rest/org/organization_slug/users/1/custom-fields/")
  .header("Secret-Access", "Secret-Access")
  .header("Api-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"custom_fields\": [\n    {\n      \"id\": 1,\n      \"type\": \"MULTIPLE\"\n    }\n  ]\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://www.crehana.com/api/v5/rest/org/organization_slug/users/1/custom-fields/', [
  'body' => '{
  "custom_fields": [
    {
      "id": 1,
      "type": "MULTIPLE"
    }
  ]
}',
  'headers' => [
    'Api-Key' => '<apiKey>',
    'Content-Type' => 'application/json',
    'Secret-Access' => 'Secret-Access',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://www.crehana.com/api/v5/rest/org/organization_slug/users/1/custom-fields/");
var request = new RestRequest(Method.POST);
request.AddHeader("Secret-Access", "Secret-Access");
request.AddHeader("Api-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"custom_fields\": [\n    {\n      \"id\": 1,\n      \"type\": \"MULTIPLE\"\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Secret-Access": "Secret-Access",
  "Api-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["custom_fields": [
    [
      "id": 1,
      "type": "MULTIPLE"
    ]
  ]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://www.crehana.com/api/v5/rest/org/organization_slug/users/1/custom-fields/")! 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()
```