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

# Associate a Trigger and Service

`POST https://api.pagerduty.com/incident_workflows/triggers/{id}/services`

Associate a Service with an existing Incident Workflow Trigger

Scoped OAuth requires: `incident_workflows.write`

## Authorization

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

## Path parameters

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string | yes | The ID of the resource. |

## 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 |
|---|---|---|---|
| `service` | object | yes |  |
| `service.id` | string |  |  |

Example: Request Example

```json
{
  "service": {
    "id": "PIJ90N7"
  }
}
```

## Response 201

The updated Incident Workflow Trigger

### `application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `trigger` | object | yes |  |
| `trigger.id` | string |  | Read-only. |
| `trigger.summary` | string \| null |  | 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. |
| `trigger.type` | string |  | One of: `workflow_trigger`. |
| `trigger.self` | string \| null (url) |  | the API show URL at which the object is accessible. Read-only. |
| `trigger.html_url` | string \| null (url) |  | a URL at which the entity is uniquely displayed in the Web app. Read-only. |
| `trigger.trigger_type_name` | string |  | Human readable name for the trigger type. |
| `trigger.trigger_type` | string |  | One of: `conditional`, `manual`, `incident_type`. |
| `trigger.condition` | string |  | A PCL condition string. If specified, the trigger will execute when the condition is met on an incident. If unspecified, the trigger will execute on incident creation. Required if trigger_type is “conditional”, not allowed for other trigger types. |
| `trigger.trigger_url` | string (url) |  |  |
| `trigger.incident_types` | array of string |  | An optional array of Incident Types associated with the trigger when it is of type `incident_type`. |
| `trigger.workflow` | object |  | Workflow to start when this trigger is invoked. |
| `trigger.workflow.id` | string |  |  |
| `trigger.workflow.type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. One of: `workflow_reference`. |
| `trigger.workflow.name` | string |  | A descriptive name for the Incident Workflow. |
| `trigger.workflow.self` | string \| null (url) |  | the API show URL at which the object is accessible. |
| `trigger.workflow.html_url` | string \| null (url) |  | a URL at which the entity is uniquely displayed in the Web app. |
| `trigger.services` | array of object |  | An optional array of Services associated with this workflow. Incidents in any of the listed Services are eligible to fire this Trigger. |
| `trigger.services[].id` | string |  |  |
| `trigger.services[].summary` | string \| null |  | 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. |
| `trigger.services[].type` | string |  | A string that determines the schema of the object. This must be the standard name for the entity, suffixed by `_reference` if the object is a reference. One of: `service`. |
| `trigger.services[].self` | string \| null (url) |  | the API show URL at which the object is accessible. |
| `trigger.services[].html_url` | string \| null (url) |  | a URL at which the entity is uniquely displayed in the Web app. |
| `trigger.is_subscribed_to_all_services` | boolean |  | Indicates that the Trigger should be associated with All Services. |
| `trigger.permissions` | object |  | An object detailing who can start this Trigger. Applicable only to manual Triggers. |
| `trigger.permissions.restricted` | boolean |  | If true, indicates that the Trigger can only be started by authorized Users. If false, any user can start this Trigger. Applicable only to manual Triggers. |
| `trigger.permissions.team_id` | string |  | The ID of the team whose members can manually start this Trigger. Required and allowed if and only if permissions.restricted is true. |
| `trigger.is_disabled` | boolean |  | Indicates whether the Trigger is disabled or not. Inherited from the "is_enabled" property on the workflow to which this trigger belongs. This attribute is deprecated, and will be removed in a future version of this API. **Deprecated.** |

Example: Response Example

```json
{
  "trigger": {
    "id": "4ad696eb-bb48-422a-8bd0-6efad6befa29",
    "type": "workflow_trigger",
    "trigger_type_name": "Conditional Trigger",
    "trigger_type": "conditional",
    "condition": "incident.priority matches 'P1'",
    "trigger_url": "https://api.pagerduty.com/incident_workflows/triggers/4ad696eb-bb48-422a-8bd0-6efad6befa29/start",
    "self": "https://api.pagerduty.com/incident_workflows/triggers/4ad696eb-bb48-422a-8bd0-6efad6befa29",
    "workflow_id": "PSFEVL7",
    "workflow_name": "Example Incident Workflow",
    "is_subscribed_to_all_services": false,
    "services": [
      {
        "id": "PIJ90N7",
        "summary": "My Application Service",
        "type": "service",
        "self": "https://api.pagerduty.com/services/PIJ90N7",
        "html_url": "https://pdt-circular.pagerduty.com/service-directory/P0544JX"
      }
    ],
    "workflow": {
      "id": "PSFEVL7",
      "name": "Example Incident Workflow",
      "description": "This Incident Workflow is an example",
      "type": "incident_workflow",
      "created_at": "2022-12-13T19:55:01.171Z",
      "self": "https://api.pagerduty.com/incident_workflows/PSFEVL7",
      "html_url": "https://mydomain.pagerduty.com/flex-workflows/workflows/PSFEVL7"
    }
  }
}
```

## 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 402

Account does not have the abilities to perform the action. Please review the response for the required abilities.
You can also use the [Abilities API](#resource_Abilities) to determine what features are available to your account.

### `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 429

Too many requests have been made, the rate limit has been reached.

### `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).
