> Documentation index for AI agents: https://docs.pagerduty.com/llms.txt

# Create a Custom Field for an Incident Type

`POST https://api.pagerduty.com/incidents/types/{type_id_or_name}/custom_fields`

Create a Custom Field for an Incident Type

Custom Fields (CF) are a feature which will allow customers to extend Incidents with their own custom data,
to provide additional context and support features such as customized filtering, search and analytics.
Custom Fields can be applied to different incident types.

Scoped OAuth requires: `custom_fields.write`

## Authorization

- **api_key** (apiKey) — `Authorization` header. The API Key with format `Token token=<API_KEY>`

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `type_id_or_name` | string | yes | The ID or name of the Incident Type. |

## Header parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `Accept` | string | yes | The `Accept` header is used as a versioning header. Default: `application/vnd.pagerduty+json;version=2`. |

## Request body (`application/json`)

| Field | Type | Required | Description |
|---|---|---|---|
| `field` | object | yes | Details of the custom field to be created. |
| `field.name` | string | yes | The name of the custom field. Max length: 50. |
| `field.display_name` | string | yes | The display name of the Incident Type. Max length: 50. |
| `field.data_type` | string | yes | The data type of the custom field. |
| `field.field_type` | string | yes | The field type of the custom field. One of: `single_value`, `single_value_fixed`, `multi_value`, `multi_value_fixed`. |
| `field.description` | string |  | The description of the custom field. Max length: 1000. |
| `field.enabled` | boolean |  | Whether the custom field is enabled. |
| `field.default_value` | string |  | The default value of the custom field. |
| `field.field_options` | array of object |  | The options for the custom field. Can only be applied to fields with a `field_type` of `single_value_fixed` or `multi_value_fixed`. When creating a fixed-value custom field, this property is required, as the field must be created with at least one field option. |
| `field.field_options[].data` | one of: object | yes |  |
| `field.field_options[].data.data_type` | string | yes | (option 1) The kind of data represented by this option. Must match the Field's `data_type`. One of: `string`. |
| `field.field_options[].data.value` | string | yes | (option 1) Max length: 100. |
| `field.field_options[].id` | string | yes | The ID of the resource. Read-only. |
| `field.field_options[].type` | string | yes | Read-only. One of: `field_option`. |
| `field.field_options[].updated_at` | string (date-time) | yes | The date/time the object was last updated. Read-only. |
| `field.field_options[].created_at` | string (date-time) | yes | The date/time the object was created at. Read-only. |

Example: Request Example

```json
{
  "field": {
    "name": "custom_field_1",
    "display_name": "Custom Field 1",
    "data_type": "string",
    "field_type": "single_value"
  }
}
```

Example: Example with Fixed Value Field

```json
{
  "field": {
    "name": "development_environment",
    "display_name": "Development Environment",
    "description": "The environment that the issue occurred in",
    "data_type": "string",
    "field_type": "single_value_fixed",
    "field_options": [
      {
        "data": {
          "data_type": "string",
          "value": "staging"
        }
      },
      {
        "data": {
          "data_type": "string",
          "value": "production"
        }
      }
    ]
  }
}
```

## Response 201

The custom field object created.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `field` | object | yes |  |
| `field.enabled` | boolean | yes | Whether the custom field is enabled. Read-only. |
| `field.id` | string | yes | The ID of the resource. Read-only. |
| `field.name` | string | yes | The name of the field. May include ASCII characters, specifically lowercase letters, digits, and underescores. The `name` for a Field must be unique and cannot be changed once created. Max length: 50. |
| `field.type` | string | yes | Read-only. One of: `field`. |
| `field.self` | string \| null (url) | yes | The API show URL at which the object is accessible. Read-only. |
| `field.description` | string \| null |  | A description of the data this field contains. Max length: 1000. |
| `field.field_type` | string | yes | The type of data this field contains. In combination with the `data_type` field. One of: `single_value`, `single_value_fixed`, `multi_value`, `multi_value_fixed`. |
| `field.data_type` | string | yes | The kind of data the custom field is allowed to contain. One of: `boolean`, `integer`, `float`, `string`, `datetime`, `url`. |
| `field.updated_at` | string (date-time) | yes | The date/time the custom field was last updated. Read-only. |
| `field.created_at` | string (date-time) | yes | The date/time the custom field was created at. Read-only. |
| `field.display_name` | string | yes | The human-readable name of the field. This must be unique across an account. Max length: 50. |
| `field.default_value` | one of: object \| object \| object \| object \| object \| object |  |  |
| `field.default_value.value` | boolean \| null |  | (Boolean) |
| `field.default_value.value` | integer \| null |  | (Integer) |
| `field.default_value.value` | number \| null |  | (Float) |
| `field.default_value.value` | one of: string \| null \| array \| null |  | (String) |
| `field.default_value.value` | string \| null (date-time) |  | (Datetime) |
| `field.default_value.value` | string \| null (uri) |  | (Url) Max length: 200. |
| `field.incident_type` | string | yes | The id of the incident type the custom field is associated with. Read-only. |
| `field.summary` | string \| null | yes | A short-form, server-generated string that provides succinct, important information about an object suitable for primary labeling of an entity in a client. In many cases, this will be identical to `name`, though it is not intended to be an identifier. Read-only. |
| `field.field_options` | array of object | yes | The options for the custom field. |
| `field.field_options[].data` | one of: object |  |  |
| `field.field_options[].data.data_type` | string | yes | (option 1) The kind of data represented by this option. Must match the Field's `data_type`. One of: `string`. |
| `field.field_options[].data.value` | string | yes | (option 1) Max length: 100. |
| `field.field_options[].id` | string | yes | The ID of the resource. Read-only. |
| `field.field_options[].type` | string | yes | Read-only. One of: `field_option`. |
| `field.field_options[].updated_at` | string (date-time) | yes | The date/time the object was last updated. Read-only. |
| `field.field_options[].created_at` | string (date-time) | yes | The date/time the object was created at. Read-only. |

Example: Response Example

```json
{
  "field": {
    "enabled": true,
    "id": "P123456",
    "name": "custom_field_1",
    "type": "field",
    "self": "https://api.pagerduty.com/incidents/types/P567890/custom_fields/P123456",
    "description": null,
    "field_type": "single_value",
    "data_type": "string",
    "updated_at": "2021-06-01T21:30:42Z",
    "created_at": "2021-06-01T21:30:42Z",
    "display_name": "Custom Field 1",
    "default_value": null,
    "incident_type": "P567890",
    "summary": "custom_field_1"
  }
}
```

Example: Example for Fixed-Value Field

```json
{
  "field": {
    "enabled": true,
    "id": "P4567",
    "name": "development_environment",
    "type": "field",
    "self": "https://api.pagerduty.com/incidents/types/P567890/custom_fields/P4567",
    "description": "The environment that the issue occurred in",
    "field_type": "single_value_fixed",
    "data_type": "string",
    "updated_at": "2021-06-01T21:30:43Z",
    "created_at": "2021-06-01T21:30:43Z",
    "display_name": "Development Environment",
    "default_value": null,
    "incident_type": "P567890",
    "summary": "development_environment",
    "field_options": [
      {
        "id": "PT4KHEE",
        "type": "field_option",
        "data": {
          "data_type": "string",
          "value": "staging"
        },
        "created_at": "2021-06-01T21:30:43Z",
        "updated_at": "2021-06-01T21:30:43Z"
      },
      {
        "id": "P5IYCNZ",
        "type": "field_option",
        "data": {
          "data_type": "string",
          "value": "production"
        },
        "created_at": "2021-06-01T21:30:42Z",
        "updated_at": "2021-06-01T21:30:42Z"
      }
    ]
  }
}
```

## Response 400

Caller provided invalid arguments. Please review the response for error details. Retrying with the same arguments will *not* work.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 401

Caller did not supply credentials or did not provide the correct credentials.
If you are using an API key, it may be invalid or your Authorization header may be malformed.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 403

Caller is not authorized to view the requested resource.
While your authentication is valid, the authenticated user or token does not have permission to perform this action.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 404

The requested resource was not found.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Response 500

Internal Server Error the PagerDuty server experienced an error.

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | object |  |  |
| `error.code` | integer |  | Read-only. |
| `error.message` | string |  | Error message string. Read-only. |
| `error.errors` | array of string |  | Read-only. |

## Developer Agreement

Your access to and use of the PagerDuty Developer Services is governed by the [PagerDuty Developer Agreement](https://docs.pagerduty.com/developer/pagerduty-developer-agreement).
