Sample - GitHub REST API
POST/orgs/{org}/campaigns

Create a campaign for an organization

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.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

1 parameter · 8 body fields
orgstringrequired
The organization name. The name is not case sensitive.
namestringrequired
The name of the campaign
descriptionstringrequired
A description for the campaign
managersarray<string>optional
The logins of the users to set as the campaign managers. At this time, only a single manager can be supplied.
team_managersarray<string>optional
The slugs of the teams to set as the campaign managers.
ends_atstringrequired
The end date and time of the campaign. The date must be in the future.
contact_linkstringoptional
The contact link of the campaign. Must be a URI.
code_scanning_alertsarray<object>optional
The code scanning alerts to include in this campaign
generate_issuesbooleanoptional
If true, will automatically generate issues for the campaign. The default is false.
Default:false

6 status codes
200Response
numberintegerrequired
The number of the newly created campaign
created_atstringrequired
The date and time the campaign was created, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
updated_atstringrequired
The date and time the campaign was last updated, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
namestringoptional
The campaign name
descriptionstringrequired
The campaign description
managersarray<SimpleUser>required
The campaign managers
team_managersarray<Team>optional
The campaign team managers
published_atstringoptional
The date and time the campaign was published, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
ends_atstringrequired
The date and time the campaign has ended, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
closed_atstringoptional
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.
statestringrequired
Indicates whether a campaign is open or closed
Allowed:openclosed
contact_linkstringrequired
The contact link of the campaign.
alert_statsobjectoptional
400Bad Request
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
404Resource not found
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Unprocessable Entity
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
429Too Many Requests
503Service unavailable
codestringoptional
messagestringoptional
documentation_urlstringoptional

Error handling

A 400 is returned: Bad Request. A 404 is returned: Resource not found. A 422 is returned: Unprocessable Entity. A 429 is returned: Too Many Requests. A 503 is returned: Service unavailable.