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

# Create Attribute Definition

Create a user attribute definition in the workspace.

Returns 409 if `name` is already used by another definition in the workspace.

The `data_type` is fixed at creation time and cannot be changed afterwards.

```json
{"openapi":"3.1.0","info":{"title":"FastAPI","version":"2.0.0"},"tags":[{"name":"Attribute Definitions"}],"servers":[{"url":"https://api-external.zenlytic.com/api/v2","description":"US"},{"url":"https://euapi-external.zenlytic.com/api/v2","description":"EU"}],"security":[{"HTTPBearer":[]}],"components":{"securitySchemes":{"HTTPBearer":{"type":"http","description":"A Personal Access Token (PAT).","scheme":"bearer"}},"schemas":{"CreateUserAttributeDefinitionSchema":{"properties":{"name":{"type":"string","title":"Name","description":"A stable, unique key for this definition within the workspace, referenced by the data model - unlike `label`, it can't be changed after creation."},"data_type":{"$ref":"#/components/schemas/UserAttributeDataType","description":"Determines the format required in `value` wherever this definition is used: \"string\" allows free text, \"number\" requires a parseable number, \"date\" requires `YYYY-MM-DD`."},"label":{"type":"string","title":"Label","description":"The human-facing display text for this definition; unlike `name`, this can be changed at any time."}},"type":"object","required":["name","data_type","label"],"title":"CreateUserAttributeDefinitionSchema"},"UserAttributeDataType":{"type":"string","enum":["string","number","date"],"title":"UserAttributeDataType"},"ApiV2Response_UserAttributeDefinitionSchema_":{"properties":{"data":{"$ref":"#/components/schemas/UserAttributeDefinitionSchema"},"meta":{"$ref":"#/components/schemas/MetaSchema"}},"type":"object","required":["data","meta"],"title":"ApiV2Response[UserAttributeDefinitionSchema]"},"UserAttributeDefinitionSchema":{"properties":{"id":{"type":"string","title":"Id"},"workspace_id":{"type":"string","title":"Workspace Id"},"name":{"type":"string","title":"Name","description":"A stable, unique key for this definition within the workspace, referenced by the data model - unlike `label`, it can't be changed after creation."},"data_type":{"$ref":"#/components/schemas/UserAttributeDataType","description":"Determines the format required in `value` wherever this definition is used: \"string\" allows free text, \"number\" requires a parseable number, \"date\" requires `YYYY-MM-DD`."},"label":{"type":"string","title":"Label","description":"The human-facing display text for this definition; unlike `name`, this can be changed at any time."}},"type":"object","required":["id","workspace_id","name","data_type","label"],"title":"UserAttributeDefinitionSchema"},"MetaSchema":{"properties":{"status":{"$ref":"#/components/schemas/ResponseStatus"},"errors":{"items":{"$ref":"#/components/schemas/ErrorSchema"},"type":"array","title":"Errors","description":"Non-empty exactly when `status` is \"error\"."},"warnings":{"items":{"$ref":"#/components/schemas/WarningSchema"},"type":"array","title":"Warnings","description":"Can be non-empty even when `status` is \"success\" - a non-fatal issue with an otherwise-successful request."}},"type":"object","required":["status"],"title":"MetaSchema"},"ResponseStatus":{"type":"string","enum":["success","error"],"title":"ResponseStatus"},"ErrorSchema":{"properties":{"message":{"type":"string","title":"Message"},"status_code":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Status Code","description":"Matches this response's actual HTTP status code."},"occurred_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Occurred At","description":"ISO 8601 UTC timestamp."},"error_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Error Code","description":"Machine-readable code for errors that need special handling (e.g. \"SSO_REQUIRED\") rather than being shown generically; null for most errors."},"error_metadata":{"anyOf":[{"$ref":"#/components/schemas/BaseErrorMetadata"},{"type":"null"}],"description":"Additional structured detail for specific error conditions; usually null."}},"type":"object","required":["message"],"title":"ErrorSchema"},"BaseErrorMetadata":{"properties":{},"type":"object","title":"BaseErrorMetadata"},"WarningSchema":{"properties":{"message":{"type":"string","title":"Message"}},"type":"object","required":["message"],"title":"WarningSchema"},"ApiV2ErrorResponse":{"properties":{"meta":{"$ref":"#/components/schemas/MetaSchema"}},"type":"object","required":["meta"],"title":"ApiV2ErrorResponse"}}},"paths":{"/workspaces/{workspace_id}/user_attribute_definitions":{"post":{"tags":["Attribute Definitions"],"summary":"Create Attribute Definition","description":"Create a user attribute definition in the workspace.\n\nReturns 409 if ``name`` is already used by another definition in the workspace.\n\nThe ``data_type`` is fixed at creation time and cannot be changed afterwards.","operationId":"create_user_attribute_definition_workspaces__workspace_id__user_attribute_definitions_post","parameters":[{"name":"workspace_id","in":"path","required":true,"schema":{"type":"string","title":"Workspace Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateUserAttributeDefinitionSchema"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiV2Response_UserAttributeDefinitionSchema_"}}}},"4XX":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiV2ErrorResponse"}}},"description":"Client Error"},"5XX":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiV2ErrorResponse"}}},"description":"Server Error"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zenlytic.com/developers/api-reference/workspace-administration/attribute-definitions/create-attribute-definition.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
