> For the complete documentation index, see [llms.txt](https://docs.bird.com/api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bird.com/api/contacts-api/api-reference/manage-contact-attribute-definition/create-attribute-definition.md).

# Create attribute definition

{% openapi src="<https://global--openapi-specs--151603429280--use1.s3.us-east-1.amazonaws.com/joined-specs/openapi.yml>" path="/workspaces/{workspaceId}/attribute-definitions" method="post" %}
<https://global--openapi-specs--151603429280--use1.s3.us-east-1.amazonaws.com/joined-specs/openapi.yml>
{% endopenapi %}

## Examples

Let's establish some of our data that will be used in the following examples:

* **Workspace ID**: a1405560-c8d3-4b1a-877d-3f449ad95352
* **AccessKey:** abcd

### Create an attribute definition

In this example, we're creating a basic attribute definition.

{% tabs %}
{% tab title="Request" %}

```bash
curl -X POST "https://api.bird.com/workspaces/a1405560-c8d3-4b1a-877d-3f449ad95352/attribute-definitions" \
-H "Content-Type: application/json" \
-H "Authorization: AccessKey abcd" \
-d '{
  "type": "string",
  "key": "countryCode",
  "displayName": "countryCode", 
  "description": "Country code",
  "pii": false,
  "cardinality": "one",
  "readOnly": false
}'
```

{% endtab %}

{% tab title="Response (200 OK)" %}

```json
{
  "key": "countryCode",
  "displayName": "countryCode",
  "description": "Country code",
  "cardinality": "one",
  "type": "string",
  "pii": false,
  "readOnly": false,
  "builtin": false,
  "archived": false,
  "createdAt": "2024-11-26T15:00:00.000Z",
  "updatedAt": "2024-11-26T15:00:00.000Z",
  "group": "custom"
}
```

{% endtab %}
{% endtabs %}

### Create an attribute definition with a format

In this example, we're creating an attribute definition and prodivding a format in order to validate the value.

{% tabs %}
{% tab title="Request" %}

```bash
curl -X POST "https://api.bird.com/workspaces/a1405560-c8d3-4b1a-877d-3f449ad95352/attribute-definitions" \
-H "Content-Type: application/json" \
-H "Authorization: AccessKey abcd" \
-d '{
  "type": "string",
  "key": "countryCode",
  "displayName": "countryCode", 
  "description": "Country code",
  "pii": false,
  "cardinality": "one",
  "readOnly": false
  "format": {
    "type": "select",
    "select": {
      "options": [
        {
          "label": "US",
          "value": "US"
        },
        {
          "label": "BR", 
          "value": "BR"
        }
      ]
    }
  }
}'
```

{% endtab %}

{% tab title="Response (200 OK)" %}

```json
{
  "key": "countryCode",
  "displayName": "countryCode",
  "description": "Country code",
  "cardinality": "one",
  "type": "string",
  "pii": false,
  "readOnly": false,
  "builtin": false,
  "archived": false,
  "createdAt": "2024-11-26T15:00:00.000Z",
  "updatedAt": "2024-11-26T15:00:00.000Z",
  "group": "custom",
  "format": {
    "type": "select",
    "select": {
      "options": [
        {
          "label": "US",
          "value": "US"
        },
        {
          "label": "BR", 
          "value": "BR"
        }
      ]
    }
  }
}
```

{% endtab %}
{% endtabs %}
