---
title: "Create a campaign for an organization"
method: POST
path: "/orgs/{org}/campaigns"
tags: ["campaigns"]
---

# Create a campaign for an organization

`POST /orgs/{org}/campaigns`

Create a campaign for an organization.

The authenticated user must be an owner or security manager for the organization to use this endpoint.

OAuth app tokens and personal access tokens (classic) need the `security_events` scope to use this endpoint.

Fine-grained tokens must have the "Code scanning alerts" repository permissions (read) on all repositories included
in the campaign.

## Path parameters

- `org` string, required

## Request body

- union
  - object
    - `name` string, required — The name of the campaign
    - `description` string, required — A description for the campaign
    - `managers` string[] — The logins of the users to set as the campaign managers. At this time, only a single manager can be supplied.
    - `team_managers` string[] — The slugs of the teams to set as the campaign managers.
    - `ends_at` string, date-time, required — The end date and time of the campaign. The date must be in the future.
    - `contact_link` string, uri, nullable — The contact link of the campaign. Must be a URI.
    - `code_scanning_alerts` object[], nullable, required — The code scanning alerts to include in this campaign
      - `repository_id` integer, required — The repository id
      - `alert_numbers` integer[], required — The alert numbers
    - `generate_issues` boolean — If true, will automatically generate issues for the campaign. The default is false.
  - object
    - `name` string, required — The name of the campaign
    - `description` string, required — A description for the campaign
    - `managers` string[] — The logins of the users to set as the campaign managers. At this time, only a single manager can be supplied.
    - `team_managers` string[] — The slugs of the teams to set as the campaign managers.
    - `ends_at` string, date-time, required — The end date and time of the campaign. The date must be in the future.
    - `contact_link` string, uri, nullable — The contact link of the campaign. Must be a URI.
    - `code_scanning_alerts` object[], nullable — The code scanning alerts to include in this campaign
      - `repository_id` integer, required — The repository id
      - `alert_numbers` integer[], required — The alert numbers
    - `generate_issues` boolean — If true, will automatically generate issues for the campaign. The default is false.

## Response `200`

Response

- CampaignSummary — The campaign metadata and alert stats.
  - `number` integer, required — The number of the newly created campaign
  - `created_at` string, date-time, required — The date and time the campaign was created, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
  - `updated_at` string, date-time, required — The date and time the campaign was last updated, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
  - `name` string — The campaign name
  - `description` string, required — The campaign description
  - `managers` SimpleUser[], required — The campaign managers
    - `name` string, nullable
    - `email` string, nullable
    - `login` string, required
    - `id` integer, required
    - `node_id` string, required
    - `avatar_url` string, uri, required
    - `gravatar_id` string, nullable, required
    - `url` string, uri, required
    - `html_url` string, uri, required
    - `followers_url` string, uri, required
    - `following_url` string, required
    - `gists_url` string, required
    - `starred_url` string, required
    - `subscriptions_url` string, uri, required
    - `organizations_url` string, uri, required
    - `repos_url` string, uri, required
    - `events_url` string, required
    - `received_events_url` string, uri, required
    - `type` string, required
    - `site_admin` boolean, required
    - `starred_at` string
    - `user_view_type` string
  - `team_managers` Team[] — The campaign team managers
    - `id` integer, required
    - `node_id` string, required
    - `name` string, required
    - `slug` string, required
    - `description` string, nullable, required
    - `privacy` string
    - `notification_setting` string
    - `permission` string, required
    - `permissions` object
      - `pull` boolean, required
      - `triage` boolean, required
      - `push` boolean, required
      - `maintain` boolean, required
      - `admin` boolean, required
    - `url` string, uri, required
    - `html_url` string, uri, required
    - `members_url` string, required
    - `repositories_url` string, uri, required
    - `type` 'enterprise' | 'organization', required — The ownership type of the team
    - `access_source` 'direct' | 'organization' | 'enterprise' — How the team's access to the repository was granted. This property is only present when the team is returned in a repository context, such as `GET /repos/{owner}/{repo}/teams`.
    - `organization_id` integer — Unique identifier of the organization to which this team belongs
    - `enterprise_id` integer — Unique identifier of the enterprise to which this team belongs
    - `parent` NullableTeamSimple, nullable, required — Groups of organization members that gives permissions on specified repositories.
      - `id` integer, required — Unique identifier of the team
      - `node_id` string, required
      - `url` string, uri, required — URL for the team
      - `members_url` string, required
      - `name` string, required — Name of the team
      - `description` string, nullable, required — Description of the team
      - `permission` string, required — Permission that the team will have for its repositories
      - `privacy` string — The level of privacy this team should have
      - `notification_setting` string — The notification setting the team has set
      - `html_url` string, uri, required
      - `repositories_url` string, uri, required
      - `slug` string, required
      - `ldap_dn` string — Distinguished Name (DN) that team maps to within LDAP environment
      - `type` 'enterprise' | 'organization', required — The ownership type of the team
      - `organization_id` integer — Unique identifier of the organization to which this team belongs
      - `enterprise_id` integer — Unique identifier of the enterprise to which this team belongs
  - `published_at` string, date-time — The date and time the campaign was published, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
  - `ends_at` string, date-time, required — The date and time the campaign has ended, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
  - `closed_at` string, date-time, nullable — The date and time the campaign was closed, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ. Will be null if the campaign is still open.
  - `state` 'open' | 'closed', required — Indicates whether a campaign is open or closed
  - `contact_link` string, uri, nullable, required — The contact link of the campaign.
  - `alert_stats` object
    - `open_count` integer, required — The number of open alerts
    - `closed_count` integer, required — The number of closed alerts
    - `in_progress_count` integer, required — The number of in-progress alerts

## Other responses

- `400` — Bad Request
- `404` — Resource not found
- `422` — Unprocessable Entity
- `429` — Too Many Requests
- `503` — Service unavailable

---

[API](https://skmtc.net/github/apis/github-v3-rest-api-3.md) · [All operations](https://skmtc.net/github/apis/github-v3-rest-api-3/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/github/github-v3-rest-api-3/versions/dc0584ac4e13/schema)
