# Create a new custom field.

`POST /admin/custom_fields`

Authentication (security requirement alternatives):

```json
[
  {
    "ApiKey": []
  }
]
```

- ApiKey: apiKey, header X-API-Key

Request body: application/json

Type: object

Schema: [CustomField](https://sourcey-azuracast.pages.dev/docs/api/models/customfield/index.md)

allOf:
  Reference: [HasAutoIncrementId](https://sourcey-azuracast.pages.dev/docs/api/models/hasautoincrementid/index.md); Type: object

  Type: object
  
  - `name` (optional)
    Type: string
  
  - `short_name` (optional)
    Type: string
    
    The programmatic name for the field. Can be auto-generated from the full name.
  
  - `auto_assign` (optional)
    Type: string; nullable
    
    An ID3v2 field to automatically assign to this value, if it exists in the media file.

Responses:

- 200: Success

Content type: application/json

Type: unknown

allOf:
  Reference: [CustomField](https://sourcey-azuracast.pages.dev/docs/api/models/customfield/index.md); Type: object

  Reference: [HasLinks](https://sourcey-azuracast.pages.dev/docs/api/models/haslinks/index.md); Type: object

- 403: Access denied.

Content type: application/json

Type: object

Schema: [Api_Error](https://sourcey-azuracast.pages.dev/docs/api/models/api-error/index.md)

- `code` (required)
  Type: integer
  
  The numeric code of the error.
  
  Example:
  
  ```json
  500
  ```

- `type` (required)
  Type: string
  
  The programmatic class of error.
  
  Example:
  
  ```json
  "NotLoggedInException"
  ```

- `message` (required)
  Type: string
  
  The text description of the error.
  
  Example:
  
  ```json
  "Error description."
  ```

- `formatted_message` (required)
  Type: string; nullable
  
  The HTML-formatted text description of the error.
  
  Example:
  
  ```json
  "<b>Error description.</b><br>Detailed error text."
  ```

- `extra_data` (required)
  Type: array
  
  Stack traces and other supplemental data.
  
  Items:
    Type: any

- `success` (required)
  Type: boolean
  
  Used for API calls that expect an \Entity\Api\Status type response.
  
  Example:
  
  ```json
  false
  ```

- 500: A generic exception has occurred.

Content type: application/json

Type: object

Schema: [Api_Error](https://sourcey-azuracast.pages.dev/docs/api/models/api-error/index.md)

- `code` (required)
  Type: integer
  
  The numeric code of the error.
  
  Example:
  
  ```json
  500
  ```

- `type` (required)
  Type: string
  
  The programmatic class of error.
  
  Example:
  
  ```json
  "NotLoggedInException"
  ```

- `message` (required)
  Type: string
  
  The text description of the error.
  
  Example:
  
  ```json
  "Error description."
  ```

- `formatted_message` (required)
  Type: string; nullable
  
  The HTML-formatted text description of the error.
  
  Example:
  
  ```json
  "<b>Error description.</b><br>Detailed error text."
  ```

- `extra_data` (required)
  Type: array
  
  Stack traces and other supplemental data.
  
  Items:
    Type: any

- `success` (required)
  Type: boolean
  
  Used for API calls that expect an \Entity\Api\Status type response.
  
  Example:
  
  ```json
  false
  ```

## Examples

### cURL

```bash
curl -X POST 'https://demo.azuracast.com/api/admin/custom_fields' \
  -H 'X-API-Key: YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "name": "string",
  "short_name": "string",
  "auto_assign": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "name": "string",
  "short_name": "string",
  "auto_assign": "string"
}`;

const response = await fetch('https://demo.azuracast.com/api/admin/custom_fields', {
  method: 'POST',
  headers: {
    'X-API-Key': 'YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "name": "string",
  "short_name": "string",
  "auto_assign": "string"
}'''

response = requests.post(
    'https://demo.azuracast.com/api/admin/custom_fields',
    data=body.encode('utf-8'),
    headers={
        'X-API-Key': 'YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
