# Create custom field

> Define a custom field for a workspace.

Source: https://docs.mycrmsim.com/docs/custom-fields/create-custom-field

```http
POST https://backend.mysmsgateway.app/api/v1/ext/custom-fields
```

- Category: myCRMSIM Contacts / Custom Fields
- Auth: Bearer access token
- Scope: `contacts.write`

Leave `field_key` out to have it made from the label (`Lead Source` → `lead_source`); a key you pass is lower-cased and anything but letters, digits and `_` becomes `_`. Keys are unique per workspace: a taken key answers **409** (update it with *Update custom field* instead). `select` and `multi_select` need `options`. Writing a value under a brand-new key on a contact also creates a `text` definition for it, so this call is for fields that need a type, options, a label or an order up front.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | body | number | yes | The workspace. Example: `7` |
| `field_label` | body | string | yes | Shown in the dashboard. Up to 100 characters. Example: `Lead Source` |
| `field_type` | body | enum | yes | How values are validated and shown. One of: `text`, `number`, `date`, `select`, `multi_select`, `url`, `email`, `phone`. Example: `select` |
| `field_key` | body | string | no | The key in `custom_fields`. Letters, digits and `_`, up to 50 characters. Default: made from the label. Example: `lead_source` |
| `options` | body | array<string> | no | The choices (required for select / multi_select; up to 100, 100 characters each). Ignored for other types. Example: `["Web","Referral","Event"]` |
| `is_required` | body | boolean | no | Marks the field required in the dashboard. Default false. Example: `false` |
| `sort_order` | body | number | no | Display position, lowest first. Default 0. Example: `1` |

## Request body

```json
{
  "workspace_id": 7,
  "field_label": "Lead Source",
  "field_type": "select",
  "options": [
    "Web",
    "Referral",
    "Event"
  ],
  "sort_order": 1
}
```

## Response 201

Created

```json
{
  "success": true,
  "message": "Custom field created",
  "data": {
    "id": 41,
    "workspace_id": 7,
    "field_key": "lead_source",
    "field_label": "Lead Source",
    "field_type": "select",
    "options": [
      "Web",
      "Referral",
      "Event"
    ],
    "is_required": false,
    "sort_order": 1,
    "created_at": "2026-11-04T02:20:00.000Z",
    "updated_at": "2026-11-04T02:20:00.000Z"
  }
}
```

## Response 400

Missing label or type, bad type, or a select without options

```json
{
  "success": false,
  "message": "options is required for a select field — an array of choices."
}
```

## Response 401

Missing or invalid token

```json
{
  "success": false,
  "message": "Invalid or expired access token."
}
```

## Response 403

Missing scope

```json
{
  "success": false,
  "message": "Missing scope(s): contacts.write. This integration was granted: …"
}
```

## Response 404

Workspace does not exist or is not owned by the installer (same response for both)

```json
{
  "success": false,
  "message": "Workspace not found or not accessible to this token"
}
```

## Response 409

The key is taken

```json
{
  "success": false,
  "code": "duplicate_field_key",
  "message": "A custom field with key \"lead_source\" already exists in this workspace. Update it with PATCH /custom-fields/41."
}
```
