# Automation

Manage Automated notifications using the `/api/pipelines` endpoints.


{{< note >}}
In the dashboard UI, we refer to pipelines as *Automation* or *Automated Messages*.

{{< /note >}}

## Create pipeline (automated message) {#createpipeline}

Create one or more pipelines. You can provide a single [pipeline object](/docs/developer/rest-api/ua/schemas/pipeline-objects/#pipelineobject) or an array of [pipeline objects](/docs/developer/rest-api/ua/schemas/pipeline-objects/#pipelineobject).

[Jump to examples ↓](#createpipeline-examples)

### `POST /api/pipelines`

**Security:**

- [basicAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-basicAuth)
- [bearerAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-bearerAuth)
- [oauth2Token]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-oauth2Token): pln

**Request body**

A single [pipeline object](/docs/developer/rest-api/ua/schemas/pipeline-objects/#pipelineobject) or an array of pipeline objects.

**Content-Type:** `application/json`

**One of:**

- [Pipeline object]({{< ref "/developer/rest-api/ua/schemas/pipeline-objects/" >}}#pipelineobject)

  A pipeline object encapsulates the complete set of objects that define an Automation pipeline: Triggers, Outcomes, and metadata. At least one of `immediate_trigger` or `historical_trigger` must be supplied.

- `array`

**Responses**

**`201`** If creating more than one pipeline, pipeline URIs are returned in the same order as the pipeline objects in the request.

Response body:

**Content-Type:** `application/vnd.urbanairship+json; version=3`

- **`ok`** `boolean`

  Success.

- **`operation_id`** `string`

  A unique string identifying a single API call.

  Format: `uuid`

  Example: `ef625038-70a3-41f1-826f-57bc11dd625a`

- **`pipeline_urls`** `array[string]`

  An array of of pipeline URIs. If more than one entity was included in the request, the URIs will be in the same order as the objects in the request.

**`400`** There was a parsing or validation error in the request. Bad Request errors typically include `path` and `location` in the response to help you find the cause of the error.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`401`** Authentication information (the app key and secret or bearer token) was either incorrect or missing.

Response body:

**Content-Type:** `text/plain`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`403`** Authentication was correct, but the user does not have permission to access the requested API, e.g., if the feature in question is not included in your pricing plan.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`409`** The request conflicts with another request.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`413`** Returned when the request is too large to be processed.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**Examples**

*Example*

```http
POST /api/pipelines HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
Content-Type: application/json

{
    "name":"The Darkest Pipeline",
    "enabled":true,
    "immediate_trigger":"first_open",
    "outcome":{
      "push":{
          "audience":"triggered",
          "device_types":[
            "ios",
            "android",
            "web"
          ],
          "notification":{
            "alert":"Cool goatee, Abed"
          }
      }
    },
    "timing":{
      "delay":{
          "seconds":7200
      },
      "schedule":{
          "type":"local",
          "miss_behavior":"wait",
          "dayparts":[
            {
                "days_of_week":[
                  "thursday"
                ],
                "allowed_times":[
                  {
                      "preferred":"21:30:00"
                  }
                ]
            }
          ]
      }
    }
}

```

```http
HTTP/1.1 201 Created
Content-Length: 123
Data-Attribute: pipeline_urls
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok": true,
    "operation_id": "86ad9239-373d-d0a5-d5d8-04fed18f79bc",
    "pipeline_urls": [
      "https://go.urbanairship/api/pipelines/86ad9239-373d-d0a5-d5d8-04fed18f79bc"
    ]
}

```

```python
from urbanairship import (
    BasicAuthClient, Automation
)
from urbanairship.automation.pipeline import Pipeline

client = BasicAuthClient(
    key='<app key>',
    secret='<master secret>'
)
automation = Automation(client)

pipeline = Pipeline(
    name='The Darkest Pipeline',
    enabled=True,
    immediate_trigger='first_open',
    outcome={
        'push': {
            'audience': 'triggered',
            'device_types': ['ios', 'android', 'web'],
            'notification': {'alert': 'Cool goatee, Abed'}
        }
    },
    timing={
        'delay': {'seconds': 7200},
        'schedule': {
            'type': 'local',
            'miss_behavior': 'wait',
            'dayparts': [{
                'days_of_week': ['thursday'],
                'allowed_times': [
                    {'preferred': '21:30:00'}
                ]
            }]
        }
    }
)
response = automation.create(pipeline.payload)

```

```ruby
require 'urbanairship'

UA = Urbanairship
airship = UA::Client.new(key: '<app key>', secret: '<master secret>')

pipeline = UA::Pipeline.new(client: airship)
pipeline.enabled = true
pipeline.immediate_trigger = "first_open"
pipeline.outcome = {
    "push": {
        "audience": "triggered",
        "device_types": ['ios','android','web'],
        "notification": {
            "alert": "Cool goatee, Abed"
        }
    }
}
automation = UA::Automation.new(client: airship)
automation.pipeline_object = pipeline.payload
details = automation.create_automation
puts(details)

```

---

## Delete pipeline {#deletepipeline}

Delete a pipeline.

[Jump to examples ↓](#deletepipeline-examples)

### `DELETE /api/pipelines/{pipeline_id}`

**Security:**

- [basicAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-basicAuth)
- [bearerAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-bearerAuth)
- [oauth2Token]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-oauth2Token): pln

**Path parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `pipeline_id` | `string` | Required | The pipeline you want to return or modify. |

**Responses**

**`204`** An API request was successful, but there is no response body to return.

**`401`** Authentication information (the app key and secret or bearer token) was either incorrect or missing.

Response body:

**Content-Type:** `text/plain`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`403`** Authentication was correct, but the user does not have permission to access the requested API, e.g., if the feature in question is not included in your pricing plan.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`404`** The requested resource doesn't exist.

Response body:

**Content-Type:** `application/vnd.urbanairship+json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**Examples**

*Example*

```http
DELETE /api/pipelines/0f927674-918c-31ef-51ca-e96fdd234da4 HTTP/1.1
Authorization: Basic <authorization string>
Accept: application/vnd.urbanairship+json; version=3

```

```http
HTTP/1.1 204 No Content

```

```python
from urbanairship import (
    BasicAuthClient, Automation
)
from urbanairship.automation.pipeline import Pipeline

client = BasicAuthClient(
    key='<app key>',
    secret='<master secret>'
)
automation = Automation(client)
response = automation.delete('0f927674-918c-31ef-51ca-e96fdd234da4')

```

```ruby
require 'urbanairship'

UA = Urbanairship
airship = UA::Client.new(key: '<app key>', secret: '<master secret>')

automation = UA::Automation.new(client: airship)
automation.pipeline_id = '0f927674-918c-31ef-51ca-e96fdd234da4'
automation.delete_automation

```

---

## Individual pipeline lookup {#getpipeline}

Fetch a single pipeline resource. Returns an array containing a single pipeline object in the `pipeline` attribute.

[Jump to examples ↓](#getpipeline-examples)

### `GET /api/pipelines/{pipeline_id}`

**Security:**

- [basicAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-basicAuth)
- [bearerAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-bearerAuth)
- [oauth2Token]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-oauth2Token): pln

**Path parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `pipeline_id` | `string` | Required | The pipeline you want to return or modify. |

**Responses**

**`200`** Returned on success, with the JSON representation of the pipeline in the body of the response.

Response body:

**Content-Type:** `application/vnd.urbanairship+json; version=3`

- **`next_page`** `string`

  An URI that points to the next page of pipelines. The page size is specified by the `limit` parameter and the start point by the `start` parameter. If there are no more pipelines for a next page we omit the next page link.

- **`ok`** `boolean`

  Success.

- **`operation_id`** `string`

  A unique string identifying a single API call.

  Format: `uuid`

  Example: `ef625038-70a3-41f1-826f-57bc11dd625a`

- **`pipeline_ids`** `array[string]`

  An array of pipeline IDs.

- **`pipeline_urls`** `array[string]`

  An array of of pipeline URIs. If more than one entity was included in the request, the URIs will be in the same order as the objects in the request.

- **`pipelines`** `array` <[Pipeline object]({{< ref "/developer/rest-api/ua/schemas/pipeline-objects/" >}}#pipelineobject)>

  A list of pipeline objects.

- **`prev_page`** `string`

  An URI that points to the previous page of pipelines. The page size is specified by the `limit` parameter and the start point by the `start` parameter. If there are no more pipelines for a previous page we omit the previous page link.

- **`total_count`** `integer`

  The total count of pipelines.

**`401`** Authentication information (the app key and secret or bearer token) was either incorrect or missing.

Response body:

**Content-Type:** `text/plain`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`403`** Authentication was correct, but the user does not have permission to access the requested API, e.g., if the feature in question is not included in your pricing plan.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`404`** The requested resource doesn't exist.

Response body:

**Content-Type:** `application/vnd.urbanairship+json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**Examples**

*Example*

```http
GET /api/pipelines/4d3ff1fd-9ce6-5ea4-5dc9-5ccbd38597f4 HTTP/1.1
Authorization: Basic <authorization string>
Accept: application/vnd.urbanairship+json; version=3

```

```http
HTTP/1.1 200 OK
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok": true,
    "pipeline": {
      "creation_time": "2020-02-14T19:19:19",
      "enabled": true,
      "immediate_trigger": { "tag_added": "new_customer" },
      "last_modified_time": "2020-03-01T12:12:54",
      "name": "New customer",
      "outcome": {
          "push": {
            "audience": "triggered",
            "device_types": [ "ios", "android" ],
            "notification": { "alert": "Hello new customer!" }
          }
      },
      "status": "live",
      "uid": "86ad9239-373d-d0a5-d5d8-04fed18f79bc",
      "url": "https://go.urbanairship/api/pipelines/86ad9239-373d-d0a5-d5d8-04fed18f79bc"
    }
}

```

```python
from urbanairship import (
    BasicAuthClient, Automation
)
from urbanairship.automation.pipeline import Pipeline

client = BasicAuthClient(
    key='<app key>',
    secret='<master secret>'
)
automation = Automation(client)
pipeline = automation.lookup('4d3ff1fd-9ce6-5ea4-5dc9-5ccbd38597f4')

```

```ruby
require 'urbanairship'

UA = Urbanairship
airship = UA::Client.new(key: '<app key>', secret: '<master secret>')

automation = UA::Automation.new(client: airship)
automation.pipeline_id = '4d3ff1fd-9ce6-5ea4-5dc9-5ccbd38597f4'
automation.lookup_automation

```

---

## List deleted pipelines {#getdeletedpipelines}

Produces a list of all deleted pipelines starting with the most recently deleted entry.

[Jump to examples ↓](#getdeletedpipelines-examples)

### `GET /api/pipelines/deleted`

**Security:**

- [basicAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-basicAuth)
- [bearerAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-bearerAuth)
- [oauth2Token]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-oauth2Token): pln

**Query parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `start` | `string` |  | The [date-time](/docs/developer/rest-api/ua/introduction/#date-time-format) of the starting element for paginating results. |
| `limit` | `integer` |  | The maximum number of elements to return. |

**Responses**

**`200`** Returns an array of deleted pipeline objects.

Response body:

**Content-Type:** `application/vnd.urbanairship+json; version=3`

- **`ok`** `boolean`

  Success.

- **`pipelines`** `array[object]`
**`401`** Authentication information (the app key and secret or bearer token) was either incorrect or missing.

Response body:

**Content-Type:** `text/plain`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`403`** Authentication was correct, but the user does not have permission to access the requested API, e.g., if the feature in question is not included in your pricing plan.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**Examples**

*Example*

```http
GET /api/pipelines/deleted/ HTTP/1.1
Authorization: Basic <authorization string>
Accept: application/vnd.urbanairship+json; version=3

```

```http
HTTP/1.1 200 OK
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok": true,
    "pipelines": [
      {
          "deletion_time": "2020-03-31T20:54:45",
          "pipeline_id": "0sdicj23-fasc-4b2f-zxcv-0baf934f0d69"
      },
      {
          "..."
      }
    ]
}

```

```python
from urbanairship import (
    BasicAuthClient, Automation
)
from urbanairship.automation.pipeline import Pipeline

client = BasicAuthClient(
    key='<app key>',
    secret='<master secret>'
)
automation = Automation(client)
response = automation.list_deleted_automations()

```

```ruby
require 'urbanairship'

UA = Urbanairship
airship = UA::Client.new(key: '<app key>', secret: '<master secret>')

automation = UA::Automation.new(client: airship)
automation.start = 2020-11-23
automation.list_deleted_automations

```

---

## List existing pipelines {#getpipelines}

List existing pipelines. Pipelines are ordered by `creation_date` from newest to oldest.

[Jump to examples ↓](#getpipelines-examples)

### `GET /api/pipelines`

**Security:**

- [basicAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-basicAuth)
- [bearerAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-bearerAuth)
- [oauth2Token]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-oauth2Token): pln

**Query parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | `integer` |  | The maximum number of results to return. This is effectively the page size for the response. No default limit. For maximum performance, set your limit between 25 and 100. Min: 1 |
| `enabled` | `boolean` |  | If true, limits the listing to enabled pipelines (`"enabled": true`). If false or omitted, lists all pipelines, whether `enabled` is `true` or `false`. |
| `offset` | `integer` |  | The first result you want to return. This parameter assists in pagination. |

**Responses**

**`200`** Returned on success, with a JSON representation of pipelines matching your query parameters.

Response body:

**Content-Type:** `application/vnd.urbanairship+json; version=3`

- **`next_page`** `string`

  An URI that points to the next page of pipelines. The page size is specified by the `limit` parameter and the start point by the `start` parameter. If there are no more pipelines for a next page we omit the next page link.

- **`ok`** `boolean`

  Success.

- **`operation_id`** `string`

  A unique string identifying a single API call.

  Format: `uuid`

  Example: `ef625038-70a3-41f1-826f-57bc11dd625a`

- **`pipeline_ids`** `array[string]`

  An array of pipeline IDs.

- **`pipeline_urls`** `array[string]`

  An array of of pipeline URIs. If more than one entity was included in the request, the URIs will be in the same order as the objects in the request.

- **`pipelines`** `array` <[Pipeline object]({{< ref "/developer/rest-api/ua/schemas/pipeline-objects/" >}}#pipelineobject)>

  A list of pipeline objects.

- **`prev_page`** `string`

  An URI that points to the previous page of pipelines. The page size is specified by the `limit` parameter and the start point by the `start` parameter. If there are no more pipelines for a previous page we omit the previous page link.

- **`total_count`** `integer`

  The total count of pipelines.

**`401`** Authentication information (the app key and secret or bearer token) was either incorrect or missing.

Response body:

**Content-Type:** `text/plain`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`403`** Authentication was correct, but the user does not have permission to access the requested API, e.g., if the feature in question is not included in your pricing plan.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**Examples**

*Example*

```http
GET /api/pipelines/ HTTP/1.1
Authorization: Basic <authorization string>
Accept: application/vnd.urbanairship+json; version=3

```

```http
HTTP/1.1 200 OK
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok": true,
    "pipelines": [
      {
          "creation_time": "2020-03-20T18:37:23",
          "enabled": true,
          "immediate_trigger": {
            "tag_added": { "tag": "bought_shoes" }
          },
          "last_modified_time": "2020-03-20T19:35:12",
          "name": "Shoe buyers",
          "outcome": {
            "push": {
                "audience": "triggered",
                "device_types": [ "android" ],
                "notification": { "alert": "So you like shoes, huh?" }
            }
          },
          "status": "live",
          "uid": "3987f98s-89s3-cx98-8z89-89adjkl29zds",
          "url": "https://go.urbanairship.com/api/pipelines/3987f98s-89s3-cx98-8z89-89adjkl29zds"
      },
      {
          "..."
      }
    ]
}

```

```python
from urbanairship import (
    BasicAuthClient, Automation
)
from urbanairship.automation.pipeline import Pipeline

client = BasicAuthClient(
    key='<app key>',
    secret='<master secret>'
)
automation = Automation(client)

for pipeline in automation.list_automations():
    print(pipeline)

```

```ruby
require 'urbanairship'

UA = Urbanairship
airship = UA::Client.new(key: '<app key>', secret: '<master secret>')

automation = UA::Automation.new(client: airship)
automation.limit = 5
automation.list_automations

```

---

## List filtered pipelines {#getfilteredpipelines}

Lists all pipelines, which fulfill the provided filter criteria. Returns a response container, which contains an array of pipeline objects in the `pipelines` attribute. The response container also provides total count and links to the next page `next_page` and previous page `prev_page`, if applicable. We also always apply a sort order. By default we apply an ascending sort order on the name `name` field, but we also support a sort order on the started date `started_date` field. Pagination is always applied, which means that the pipeline result list is not the complete list of pipelines if the total count is greater than the page limit.

### `GET /api/pipelines/filtered`

**Security:**

- [basicAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-basicAuth)
- [bearerAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-bearerAuth)
- [oauth2Token]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-oauth2Token): pln

**Query parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `start` | `integer` |  | Non-negative zero-based index of the starting element for paginating results. Default value 0. Min: 1 |
| `limit` | `integer` |  | The maximum number of results to return. This is effectively the page size for the response. Min: 1 |
| `enabled` | `boolean` |  | If true, limits the listing to enabled pipelines. If false or omitted, lists all pipelines, whether `enabled` is `true` or `false`. |
| `started_date_mills` | `integer` |  | Limits the listing to only pipelines that were started after the specified date in milliseconds. |
| `prefix` | `string` |  | Search term, which is used as a prefix search term. |
| `triggers` | `string` |  | 0 or more trigger types. The triggers filter limits the listing of pipelines by the specified trigger types. For example, if you specify `REGION_EXITED` and `REGION_ENTERED`, only pipelines that are associated with region entry and region exit triggers will be shown. If no trigger types are specified, no triggers filter will be applied and all pipelines will be listed. Possible values: `TAG_ADDED`, `TAG_REMOVED`, `FIRST_REG`, `FIRST_OPT_IN`, `ACTIVITY`, `REGION_ENTERED`, `REGION_EXITED`, `CUSTOM_EVENT`, `SUBSCRIPTION_ADDED`, `SUBSCRIPTION_REMOVED` |
| `sort` | `string` |  | Specifies the field, which should be sorted. Two fields are supported: `name` and `started_date`. If you omit the `sort` parameter, the default value `name` is used. If you provide an unknown field name, we will default to the `name` field. Possible values: `name`, `started_date` |
| `order` | `string` |  | Specifies the sort order as ascending (`asc`) or descending (`desc`). If you omit the `order` parameter, the default value `asc` is used. Possible values: `asc`, `desc` |

**Responses**

**`200`** Returned on success, with a JSON representation of pipelines matching your query parameters.

Response body:

**Content-Type:** `application/vnd.urbanairship+json; version=3`

- **`next_page`** `string`

  An URI that points to the next page of pipelines. The page size is specified by the `limit` parameter and the start point by the `start` parameter. If there are no more pipelines for a next page we omit the next page link.

- **`ok`** `boolean`

  Success.

- **`operation_id`** `string`

  A unique string identifying a single API call.

  Format: `uuid`

  Example: `ef625038-70a3-41f1-826f-57bc11dd625a`

- **`pipeline_ids`** `array[string]`

  An array of pipeline IDs.

- **`pipeline_urls`** `array[string]`

  An array of of pipeline URIs. If more than one entity was included in the request, the URIs will be in the same order as the objects in the request.

- **`pipelines`** `array` <[Pipeline object]({{< ref "/developer/rest-api/ua/schemas/pipeline-objects/" >}}#pipelineobject)>

  A list of pipeline objects.

- **`prev_page`** `string`

  An URI that points to the previous page of pipelines. The page size is specified by the `limit` parameter and the start point by the `start` parameter. If there are no more pipelines for a previous page we omit the previous page link.

- **`total_count`** `integer`

  The total count of pipelines.

**`401`** Authentication information (the app key and secret or bearer token) was either incorrect or missing.

Response body:

**Content-Type:** `text/plain`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`403`** Authentication was correct, but the user does not have permission to access the requested API, e.g., if the feature in question is not included in your pricing plan.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

---

## List pipelines constraints {#getpipelinesconstraints}

Returns an array of cross-pipeline rate limit constraints. These are the rates that the combination of all pipelines for an app may not exceed.

[Jump to examples ↓](#getpipelinesconstraints-examples)

### `GET /api/pipelines/constraints`

**Security:**

- [basicAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-basicAuth)
- [bearerAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-bearerAuth)
- [oauth2Token]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-oauth2Token): pln

**Responses**

**`200`** Returns an array of cross-pipeline rate limit constraints.

Response body:

**Content-Type:** `application/vnd.urbanairship+json; version=3`

- **`constraints`** `array[object]`

  An array of rate objects determining the maximum number of messages each audience member can receive over a period of time.

- **`ok`** `boolean`

  Success.

**`401`** Authentication information (the app key and secret or bearer token) was either incorrect or missing.

Response body:

**Content-Type:** `text/plain`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`403`** Authentication was correct, but the user does not have permission to access the requested API, e.g., if the feature in question is not included in your pricing plan.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**Examples**

*Example*

```http
GET /api/pipelines/constraints/ HTTP/1.1
Authorization: Basic <authorization string>
Accept: application/vnd.urbanairship+json; version=3

```

```http
HTTP/1.1 200 OK
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok": true,
    "constraints" : [
        {
            "rate" : {
                "pushes" : 30,
                "lifetimes" : 1
            }
        },
        {
            "rate" : {
                "pushes" : 15,
                "days" : 3
            }
        },
        {
            "rate" : {
                "pushes" : 4,
                "hours" : 6
            }
        }
    ]
}

```

---

## List pipelines limits {#getpipelineslimits}

Return the currently configured limits for number of total and active pipelines, as well as the total and active counts.

[Jump to examples ↓](#getpipelineslimits-examples)

### `GET /api/pipelines/limits`

**Security:**

- [basicAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-basicAuth)
- [bearerAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-bearerAuth)
- [oauth2Token]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-oauth2Token): pln

**Responses**

**`200`** Returns a JSON dictionary in the `limits` attribute.

Response body:

**Content-Type:** `application/vnd.urbanairship+json; version=3`

- **`limits`** `object`
  **OBJECT PROPERTIES**

  - **`active_count`** `integer`

    An integer indicating the number of pipelines created by the application which are currently enabled.

  - **`active_limit`** `integer`

    An integer indicating the total number of active pipelines that the app is allowed to have.

  - **`total_count`** `integer`

    An integer indicating the total number of pipelines that currently exist for the application, regardless of their enabled state.

  - **`total_limit`** `integer`

    An integer indicating the total number of pipelines that the app is allowed to have, regardless of their enabled state.

- **`ok`** `boolean`

  Success.

**`401`** Authentication information (the app key and secret or bearer token) was either incorrect or missing.

Response body:

**Content-Type:** `text/plain`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`403`** Authentication was correct, but the user does not have permission to access the requested API, e.g., if the feature in question is not included in your pricing plan.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**Examples**

*Example*

```http
GET /api/pipelines/limits/ HTTP/1.1
Authorization: Basic <authorization string>
Accept: application/vnd.urbanairship+json; version=3

```

```http
HTTP/1.1 200 OK
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok": true,
    "limits" : {
        "total_limit" : 50,
        "active_limit" : 20,
        "total_count" : 23,
        "active_count" : 7
    }
}

```

---

## Update pipeline {#updatepipeline}

Update the state of a single pipeline resource. You must include the complete payload from a POST response, with changes you want to make to the resource. You cannot provide a partial payload. If you omit optional fields during this operation that were already set for the pipeline, they will be nullified.

[Jump to examples ↓](#updatepipeline-examples)

### `PUT /api/pipelines/{pipeline_id}`

**Security:**

- [basicAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-basicAuth)
- [bearerAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-bearerAuth)
- [oauth2Token]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-oauth2Token): pln

**Path parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `pipeline_id` | `string` | Required | The pipeline you want to return or modify. |

**Request body**

A single pipeline object or an array of pipeline objects.

**Content-Type:** `application/json`

[Pipeline object]({{< ref "/developer/rest-api/ua/schemas/pipeline-objects/" >}}#pipelineobject)

**Responses**

**`200`** Returned if the pipeline has been successfully updated.

Response body:

**Content-Type:** `application/vnd.urbanairship+json; version=3`

[OK response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#okresponseobject)

**`400`** There was a parsing or validation error in the request. Bad Request errors typically include `path` and `location` in the response to help you find the cause of the error.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`401`** Authentication information (the app key and secret or bearer token) was either incorrect or missing.

Response body:

**Content-Type:** `text/plain`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`403`** Authentication was correct, but the user does not have permission to access the requested API, e.g., if the feature in question is not included in your pricing plan.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`409`** The request conflicts with another request.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`413`** Returned when the request is too large to be processed.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**Examples**

*Example*

```http
PUT /api/pipelines/0f927674-918c-31ef-51ca-e96fdd234da4 HTTP/1.1
Authorization: Basic <authorization string>
Accept: application/vnd.urbanairship+json; version=3
Content-Type: application/json;

{
    "enabled": true,
    "immediate_trigger": {
      "tag_added": "new_customer"
    },
    "outcome": {
      "push": {
          "audience": "triggered",
          "device_types": [
            "ios"
          ],
          "notification": {
            "alert": "Hello new customer!"
          }
      }
    }
}

```

```http
HTTP/1.1 200 OK
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok": true
}

```

```python
from urbanairship import (
    BasicAuthClient, Automation
)
from urbanairship.automation.pipeline import Pipeline

client = BasicAuthClient(
    key='<app key>',
    secret='<master secret>'
)
automation = Automation(client)

pipeline = Pipeline(
    enabled=True,
    immediate_trigger={
        'tag_added': 'new_customer'
    },
    outcome={
        'audience': 'triggered',
        'device_types': ['ios'],
        'notification': notification(alert='Hello new customer!')
    }
)
response = automation.update(
    pipeline_id='0f927674-918c-31ef-51ca-e96fdd234da4',
    pipeline=pipeline.payload
)

```

```ruby
require 'urbanairship'

UA = Urbanairship
airship = UA::Client.new(key: '<app key>', secret: '<master secret>')

pipeline = UA::Pipeline.new(client: airship)
pipeline.enabled = true
pipeline.immediate_trigger = {
  "tag_added": {
     "tag": "new_customer",
     "group": "crm"
    }
}
pipeline.outcome = {
  "push": {
     "audience": "triggered",
     "device_types": ["ios"],
     "notification": {
         "alert": "Hello new customer!"
        }
    }
}
automation = UA::Automation.new(client: airship)
automation.pipeline_id = '0f927674-918c-31ef-51ca-e96fdd234da4'
automation.pipeline_object = pipeline.payload
automation.update_automation

```

---

## Update pipelines constraints {#updatepipelineconstraints}

Update the pipelines constraints.

[Jump to examples ↓](#updatepipelineconstraints-examples)

### `PUT /api/pipelines/constraints`

**Security:**

- [basicAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-basicAuth)
- [bearerAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-bearerAuth)
- [oauth2Token]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-oauth2Token): pln

**Request body**

An array of no more than 5 cross-pipeline rate limit constraints.

**Content-Type:** `application/json`

- **`constraints`** `array[object]`

  An array of rate objects determining the maximum number of messages each audience member can receive over a period of time.

  Max items: 5

- **`ok`** `boolean`

  Success.

**Responses**

**`200`** Everything worked as expected.

Response body:

**Content-Type:** `application/vnd.urbanairship+json; version=3`

[OK response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#okresponseobject)

**`400`** There was a parsing or validation error in the request. Bad Request errors typically include `path` and `location` in the response to help you find the cause of the error.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`401`** Authentication information (the app key and secret or bearer token) was either incorrect or missing.

Response body:

**Content-Type:** `text/plain`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`403`** Authentication was correct, but the user does not have permission to access the requested API, e.g., if the feature in question is not included in your pricing plan.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**Examples**

*Example*

```http
PUT /api/pipelines/constraints/ HTTP/1.1
Authorization: Basic <authorization string>
Accept: application/vnd.urbanairship+json; version=3
Content-Type: application/json

{
    "constraints" : [
        {
            "rate" : {
                "pushes" : 15,
                "days" : 3
            }
        },
        {
            "rate" : {
                "pushes" : 4,
                "hours" : 6
            }
        }
    ]
}

```

```http
HTTP/1.1 200 OK
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok": true
}

```

---

## Validate pipeline {#validatepipeline}

This endpoint accepts the same range of payloads as a `POST` to `/api/pipelines`, but only parses and validates the payload, without creating the pipeline. The body of the request must be a single pipeline object or an array of pipeline objects.

[Jump to examples ↓](#validatepipeline-examples)

### `POST /api/pipelines/validate`

**Security:**

- [basicAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-basicAuth)
- [bearerAuth]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-bearerAuth)
- [oauth2Token]({{< ref "/developer/rest-api/ua/introduction/" >}}#security-oauth2Token): pln

**Request body**

A single pipeline object or an array of pipeline objects.

**Content-Type:** `application/json`

**One of:**

- [Pipeline object]({{< ref "/developer/rest-api/ua/schemas/pipeline-objects/" >}}#pipelineobject)

  A pipeline object encapsulates the complete set of objects that define an Automation pipeline: Triggers, Outcomes, and metadata. At least one of `immediate_trigger` or `historical_trigger` must be supplied.

- `array`

**Responses**

**`200`** Everything worked as expected.

Response body:

**Content-Type:** `application/vnd.urbanairship+json; version=3`

[OK response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#okresponseobject)

**`400`** There was a parsing or validation error in the request. Bad Request errors typically include `path` and `location` in the response to help you find the cause of the error.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`401`** Authentication information (the app key and secret or bearer token) was either incorrect or missing.

Response body:

**Content-Type:** `text/plain`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`406`** Return when the client requests a version of the API that cannot be satisfied, because no compatible version is currently deployed.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**`413`** Returned when the request is too large to be processed.

Response body:

**Content-Type:** `application/json`

[Error response]({{< ref "/developer/rest-api/ua/schemas/responses/" >}}#error)

**Examples**

*Example*

```http
POST /api/pipelines/validate HTTP/1.1
Authorization: Basic <master authorization string>
Accept: application/vnd.urbanairship+json; version=3
Content-Type: application/json

{
    "name":"The Darkest Pipeline",
    "enabled":true,
    "immediate_trigger":"first_open",
    "outcome":{
      "push":{
          "audience":"triggered",
          "device_types":[
            "ios",
            "android"
          ],
          "notification":{
            "alert":"Cool goatee, Abed"
          }
      }
    },
    "timing":{
      "delay":{
          "seconds":7200
      },
      "schedule":{
          "type":"local",
          "miss_behavior":"wait",
          "dayparts":[
            {
                "days_of_week":[
                  "thursday"
                ],
                "allowed_times":[
                  {
                      "preferred":"21:30:00"
                  }
                ]
            }
          ]
      }
    }
}

```

```http
HTTP/1.1 200 OK
Content-Length: 11
Content-Type: application/vnd.urbanairship+json; version=3

{
    "ok": true
}

```

```python
from urbanairship import (
    BasicAuthClient, Automation
)
from urbanairship.automation.pipeline import Pipeline

client = BasicAuthClient(
    key='<app key>',
    secret='<master secret>'
)
automation = Automation(client)

pipeline = Pipeline(
    name='The Darkest Pipeline',
    enabled=True,
    immediate_trigger='first_open',
    outcome={
        'push': {
            'audience': 'triggered',
            'device_types': ['ios', 'android', 'web'],
            'notification': notification(alert='Cool goatee, Abed')
        }
    },
    timing={
        'delay': {'seconds': 7200},
        'schedule': {
            'type': 'local',
            'miss_behavior': 'wait',
            'dayparts': [{
                'days_of_week': ['thursday'],
                'allowed_times': [
                    {'preferred': '21:30:00'}
                ]
            }]
        }
    }
)
response = automation.validate(pipeline.payload)

```

```ruby
require 'urbanairship'

UA = Urbanairship
airship = UA::Client.new(key: '<app key>', secret: '<master secret>')

pipeline = UA::Pipeline.new(client: airship)
pipeline.enabled = true
pipeline.immediate_trigger = "first_open"
pipeline.outcome = {
    "push": {
        "audience": "triggered",
        "device_types": ['ios','android','web'],
        "notification": {
            "alert": "Cool goatee, Abed"
        }
    }
}
automation = UA::Automation.new(client: airship)
automation.pipeline_object = pipeline.payload
automation.validate_automation

```

---

