[Tenjin API Reference](https://api-docs.tenjin.com/llms.txt) › [Campaign Management API](https://api-docs.tenjin.com/campaign-management-api.md) › Update a campaign

- Campaign Management API OpenAPI spec: https://api-docs.tenjin.com/openapi/campaign-management-api.json

# Update a campaign

- **Method:** `PATCH`
- **Path:** `/v2/campaigns/{id}`
- **Operation ID:** `patch_campaigns_id`
- **Tags:** Campaigns

## Effective servers

- `https://api.tenjin.com`

## Authentication

- **Bearer**: HTTP bearer (`JWT`)

  Generate an access token on the [Access Tokens](https://dashboard.tenjin.com/dashboard/access_tokens) page of the Tenjin dashboard and send it as `Authorization: Bearer <access token>`. [API access tokens](https://tenjin.com/docs/api-access-tokens/) explains them.

## Path parameters

- **`id` (required)**: `string`, format: `uuid`

  Id of the campaign

## Request body

**Required:** `false`

**Content type:** `application/json`

schema: `patch_campaigns_id_Request`

- **`attribution_window`**: `integer | null`

  Click attribution window in seconds. Absent or null leaves the window unchanged, so a campaign cannot go back to the ad account's window. Attribution does not use it: it uses the app's attribution windows and the integration's attribution settings

**Example:**

```json
{
  "attribution_window": null
}
```

## Responses

### 200 The updated campaign

**Content type:** `application/json`

schema: `CampaignDocument`

- **`data` (required)**: `object`, schema: `CampaignResource`
  - **`attributes` (required)**: `object`
    - **`ad_account_id` (required)**: `string | null`, format: `uuid`

      Id of the campaign's ad account
    - **`app_id` (required)**: `string | null`, format: `uuid`

      Id of the app the campaign promotes
    - **`attribution_window` (required)**: `integer | null`

      Click attribution window in seconds. Null uses the ad account's window. Attribution does not use it: it uses the app's attribution windows and the integration's attribution settings
    - **`channel_id` (required)**: `integer`

      Id of the campaign's channel
    - **`click_tracking_url` (required)**: `string | null`

      Click tracking URL of the campaign, with the ad network's macros left as is
    - **`created_at` (required)**: `string | null`, format: `date-time`

      When the campaign was created
    - **`hidden` (required)**: `boolean`

      Whether the campaign is deleted
    - **`impression_tracking_url` (required)**: `string | null`

      Impression tracking URL of the campaign, with the ad network's macros left as is
    - **`name` (required)**: `string | null`

      Name of the campaign in Tenjin
    - **`remote_campaign_id` (required)**: `string | null`

      Id of the campaign on the ad network
    - **`short_id` (required)**: `string | null`

      URL-safe id of the campaign in Tenjin
  - **`id` (required)**: `string`, format: `uuid`
  - **`type` (required)**: `string`, possible values: `"campaign"`
- **`links` (required)**: `object`, schema: `Links`
  - **`self` (required)**: `string`, format: `uri`

    URL of this request
  - **`first`**: `string`, format: `uri`

    URL of the first page of a list
  - **`last`**: `string`, format: `uri`

    URL of the last page of a list
  - **`next`**: `string`, format: `uri`

    URL of the next page of a list
  - **`prev`**: `string`, format: `uri`

    URL of the previous page of a list
- **`meta` (required)**: `object`

  Always empty

**Example: The updated campaign**

```json
{
  "data": {
    "id": "41149a48-9766-4c23-7744-56cb4836a603",
    "type": "campaign",
    "attributes": {
      "channel_id": 3,
      "app_id": "17ef8c1a-5729-456e-98db-ccc104bdf860",
      "ad_account_id": "6e3fbfa6-27cc-45f2-af3f-5c9ead45280e",
      "name": "Facebook Campaign",
      "short_id": "zzzk0TXwNXu7Y5Maf2aRkL",
      "remote_campaign_id": "48249a48-9766-4c23-8c13-56cb4836d903",
      "click_tracking_url": "https://tenjin.io/v0/click/zzzk0TXwNXu7Y5Maf2aRkL",
      "impression_tracking_url": null,
      "attribution_window": null,
      "created_at": "2019-08-20T21:56:12.336Z",
      "hidden": false
    }
  },
  "links": {
    "self": "https://api.tenjin.com/v2/campaigns/41149a48-9766-4c23-7744-56cb4836a603"
  },
  "meta": {}
}
```

### 400, 401, 403, 498, 503

- `400` A param is missing or invalid, a record is not found, or the request cannot be served
- `401` Missing or invalid credentials, or no access to the requested data
- `403` Invalid token, or the user's role does not allow the request
- `498` Expired token, or a token with an invalid signature
- `503` Read-only mode during maintenance; try again later

**Content type:** `application/json`

schema: `Error`

- **`error` (required)**: `string`

  What went wrong

**Example:**

```json
{
  "error": ""
}
```

## Schemas

- `Error` — shown above.
- `CampaignDocument` — shown above.
- `patch_campaigns_id_Request` — shown above.
- `Links` — shown above.
- `CampaignResource` — shown above.
