---
title: "Create a campaign"
method: POST
path: "/v2/campaigns"
tags: ["Campaigns"]
---

# Create a campaign

`POST /v2/campaigns`

## Request

- Base URL: `https://api.tenjin.com`
- URL: `https://api.tenjin.com/v2/campaigns`
- Auth: HTTP bearer

## Request body

- PostCampaignsRequest
  - `name` string, required: Name of the campaign
  - `app_id` string, uuid, required: Id of the app the campaign promotes
  - `channel_id` integer: Id of the channel. Send channel_id, ad_account_id or both; both must name the same channel
  - `ad_account_id` string, uuid: Id of the ad account. Without it, Tenjin finds or creates the organization's ad account for the channel
  - `attribution_window` integer, nullable: Click attribution window in seconds. Absent or 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

## Response `201`

The created campaign

- CampaignDocument
  - `data` CampaignResource, required
    - `id` string, uuid, required
    - `type` 'campaign', required
    - `attributes` object, required
      - `channel_id` integer, required: Id of the campaign's channel
      - `app_id` string, uuid, nullable, required: Id of the app the campaign promotes
      - `ad_account_id` string, uuid, nullable, required: Id of the campaign's ad account
      - `name` string, nullable, required: Name of the campaign in Tenjin
      - `short_id` string, nullable, required: URL-safe id of the campaign in Tenjin
      - `remote_campaign_id` string, nullable, required: Id of the campaign on the ad network
      - `click_tracking_url` string, nullable, required: Click tracking URL of the campaign, with the ad network's macros left as is
      - `impression_tracking_url` string, nullable, required: Impression tracking URL of the campaign, with the ad network's macros left as is
      - `attribution_window` integer, nullable, required: 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
      - `created_at` string, date-time, nullable, required: When the campaign was created
      - `hidden` boolean, required: Whether the campaign is deleted
  - `links` Links, required
    - `self` string, uri, required: URL of this request
    - `first` string, uri: URL of the first page of a list
    - `prev` string, uri: URL of the previous page of a list
    - `next` string, uri: URL of the next page of a list
    - `last` string, uri: URL of the last page of a list
  - `meta` object, required: Always empty

## Other responses

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

---

[API](https://skmtc.dev/tenjin/apis/campaign-management-api.md) - [All operations](https://skmtc.dev/tenjin/apis/campaign-management-api/llms.txt) - [OpenAPI document](https://skmtc.dev/tenjin/apis/campaign-management-api/revisions/e3cae1a03a92?raw)
