> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gomobile.ma/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom Attributes

> Define and manage custom data fields for contacts

<Info>
  **Base path: `/custom-attributes`**
</Info>

## Types

<Accordion title="Type Definitions">
  ```typescript theme={null}
  // ============ Enums ============

  type CustomAttributeType =
    | 'text'
    | 'number'
    | 'boolean'
    | 'date'
    | 'phone_number'
    | 'email'
    | 'url';

  // ============ Request Types ============

  interface CreateCustomAttributeRequest {
    displayName: string;          // 3-64 characters
    description?: string;         // 1-256 characters
    type: CustomAttributeType;
  }

  interface UpdateCustomAttributeRequest {
    description?: string;         // 1-256 characters
  }

  // ============ Response Types ============

  interface CustomAttributeResponse {
    id: string;
    organizationId: string;
    name: string;                 // auto-generated slug from displayName
    displayName: string;
    description: string | null;
    type: CustomAttributeType;
    createdAt: string;            // ISO date
    updatedAt: string;            // ISO date
    deletedAt: string | null;
    createdBy: string | null;
    updatedBy: string | null;
    deletedBy: string | null;
  }
  ```
</Accordion>

### Get all custom attributes

```bash theme={null}
curl -X GET https://api.gomobile.ma/api/custom-attributes \
  -H "x-api-key: YOUR_API_KEY"
```

Response:

```json theme={null}
[
  {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "organizationId": "660e8400-e29b-41d4-a716-446655440001",
    "name": "customer_age",
    "displayName": "Customer Age",
    "description": "Age of the customer in years",
    "type": "number",
    "createdAt": "2025-01-15T10:30:00.000Z",
    "updatedAt": "2025-01-15T10:30:00.000Z",
    "deletedAt": null,
    "createdBy": null,
    "updatedBy": null,
    "deletedBy": null
  }
]
```

***

### Get custom attribute by ID

```bash theme={null}
curl -X GET https://api.gomobile.ma/api/custom-attributes/550e8400-e29b-41d4-a716-446655440000 \
  -H "x-api-key: YOUR_API_KEY"
```

Response:

```json theme={null}
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "organizationId": "660e8400-e29b-41d4-a716-446655440001",
  "name": "customer_age",
  "displayName": "Customer Age",
  "description": "Age of the customer in years",
  "type": "number",
  "createdAt": "2025-01-15T10:30:00.000Z",
  "updatedAt": "2025-01-15T10:30:00.000Z",
  "deletedAt": null,
  "createdBy": null,
  "updatedBy": null,
  "deletedBy": null
}
```

***

### Create a new custom attribute

```bash theme={null}
curl -X POST https://api.gomobile.ma/api/custom-attributes \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '
{
  "displayName": "Customer Age",
  "description": "Age of the customer in years",
  "type": "number"
}
'
```

Response:

```json theme={null}
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "organizationId": "660e8400-e29b-41d4-a716-446655440001",
  "name": "customer_age",
  "displayName": "Customer Age",
  "description": "Age of the customer in years",
  "type": "number",
  "createdAt": "2025-01-15T10:30:00.000Z",
  "updatedAt": "2025-01-15T10:30:00.000Z",
  "deletedAt": null,
  "createdBy": null,
  "updatedBy": null,
  "deletedBy": null
}
```

***

### Update custom attribute

```bash theme={null}
curl -X PUT https://api.gomobile.ma/api/custom-attributes/550e8400-e29b-41d4-a716-446655440000 \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '
{
  "description": "Updated description for customer age"
}
'
```

Response:

```json theme={null}
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "organizationId": "660e8400-e29b-41d4-a716-446655440001",
  "name": "customer_age",
  "displayName": "Customer Age",
  "description": "Updated description for customer age",
  "type": "number",
  "createdAt": "2025-01-15T10:30:00.000Z",
  "updatedAt": "2025-01-15T12:00:00.000Z",
  "deletedAt": null,
  "createdBy": null,
  "updatedBy": null,
  "deletedBy": null
}
```

***

### Delete custom attribute

```bash theme={null}
curl -X DELETE https://api.gomobile.ma/api/custom-attributes/550e8400-e29b-41d4-a716-446655440000 \
  -H "x-api-key: YOUR_API_KEY"
```

Response:

```json theme={null}
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  ...
}
```
