> For AI agents: [llms.txt](https://docs.trustedauth.com/llms.txt) provides a Markdown index of this documentation.

# Create a user attribute

`POST /api/web/v1/userattributes`

Create a  user attribute. Caller requires the USERATTRIBUTES:ADD permission.

## Request Body

Required.

### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "mandatory": {
      "type": "boolean",
      "description": "A flag indicating if users must have a value for this user attribute. If not specified when creating a user attribute if defaults to false."
    },
    "name": {
      "type": "string",
      "description": "The name of this user attribute. This must be specified when creating a user attribute."
    },
    "type": {
      "type": "string",
      "description": "Type of user attribute.",
      "example": "OTP_EMAIL",
      "enum": [
        "NONE",
        "OTP_EMAIL",
        "OTP_SMS",
        "OTP_VOICE",
        "OTP_WECHAT",
        "OTP_WHATSAPP"
      ]
    },
    "unique": {
      "type": "boolean",
      "description": "A flag indicating if this attribute is intended to be unique. If not specified when creating a user attribute it defaults to false."
    }
  },
  "description": "The parameters for the new user attribute.",
  "title": "UserAttributeParms"
}
```

## Responses

### 200

Successful

#### application/json

Schema

```json
{
  "required": [
    "mandatory",
    "name",
    "systemDefined",
    "unique"
  ],
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "The UUID for this user attribute.  Generated when the user attribute is created."
    },
    "mandatory": {
      "type": "boolean",
      "description": "A flag indicating if users must have a value for this user attribute."
    },
    "name": {
      "type": "string",
      "description": "The name of this user attribute."
    },
    "systemDefined": {
      "type": "boolean",
      "description": "A flag indicating if this user attribute is one of the system defined user attributes."
    },
    "type": {
      "type": "string",
      "description": "Type of user attribute. Currently only used to specify the type of contact if the attribute is to be used for OTP delivery.",
      "example": "OTP_EMAIL",
      "enum": [
        "NONE",
        "OTP_EMAIL",
        "OTP_SMS",
        "OTP_VOICE",
        "OTP_WECHAT",
        "OTP_WHATSAPP"
      ]
    },
    "unique": {
      "type": "boolean",
      "description": "A flag indicating if this attribute is intended to be unique."
    }
  },
  "description": "Information about user attribute definitions.",
  "title": "UserAttribute"
}
```

### 400

Bad Request

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

### 401

Access denied

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

### 403

Forbidden

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

### 404

Not Found

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

### 409

Conflict

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

## Security

Requirements

```json
[
  {
    "AdminAPIAuthentication": [
      "USERATTRIBUTES:ADD"
    ]
  }
]
```
