Swat.io Developer DocumentationSwat.io Developer Documentation
Home
Getting Started
  • Overview
  • Core Resources
  • Posts
  • Drafts
  • Campaigns
  • Asset Library
MCP
Home
Getting Started
  • Overview
  • Core Resources
  • Posts
  • Drafts
  • Campaigns
  • Asset Library
MCP
  • Campaigns

Campaigns

Campaigns group related posts within a workspace. Posts added to a campaign inherit the campaign's tags, and the campaign's start/end dates bound the window in which those posts are expected to publish.

Available fields

FieldTypeDescription
idIDUnique identifier
nameStringCampaign name
notesStringOptional free-form notes
color_numberIntReferences a predefined color in the UI
icon_numberIntReferences a predefined icon in the UI
date_fromDateStart date of the campaign
date_toDateEnd date of the campaign
tags[String!]Tags applied to the campaign. New posts linked to the campaign inherit these.
post_countsIntNumber of posts linked to the campaign
workspace_idIDThe workspace the campaign belongs to

List campaigns

query listCampaigns {
  campaigns(workspace_id: <WORKSPACE_ID>) {
    id
    name
    date_from
    date_to
    post_counts
  }
}

Fetch a single campaign

query getCampaign {
  campaign(id: <CAMPAIGN_ID>) {
    id
    name
    notes
    date_from
    date_to
    tags
    post_counts
    can_view_all_posts
    can_mutate_tags_on_all_posts
  }
}

Create

Required: name, date_from, date_to, workspace_id. Everything else is optional.

mutation campaignCreate {
  campaignCreate(
    workspace_id: <WORKSPACE_ID>
    name: "Q3 Launch"
    date_from: "2025-07-01"
    date_to: "2025-09-30"
    notes: "Coordinated launch across LinkedIn and X"
    color_number: 3
    icon_number: 7
    tags: ["launch", "q3"]
  ) {
    id
    name
  }
}

Update

All fields are optional except id. tags has replace semantics: passing null (or omitting it) leaves tags untouched, passing an empty array [] removes all tags, and passing a list replaces the current tags with the provided list.

mutation campaignUpdate {
  campaignUpdate(
    id: <CAMPAIGN_ID>
    name: "Q3 Launch - revised"
    tags: ["launch", "q3", "priority"]
  ) {
    id
    name
    tags
  }
}

Delete

mutation campaignDelete {
  campaignDelete(id: <CAMPAIGN_ID>)
}

The optional remove_tags_on_posts: Boolean argument (default false) also removes the campaign's tags from every post linked to the campaign. Using it requires permission to mutate tags on all of the campaign's posts.

mutation campaignDeleteWithTags {
  campaignDelete(id: <CAMPAIGN_ID>, remove_tags_on_posts: true)
}

Linking a post to a campaign

Pass campaign_id to postCreate to link a new post to an existing campaign. See Posts.