Skip to content

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.

API method documentation

org
required
string

The organization name. The name is not case sensitive.

Media type application/json
One of:
object
name

The name of the campaign

string
>= 1 characters <= 50 characters
description

A description for the campaign

string
>= 1 characters <= 255 characters
managers

The logins of the users to set as the campaign managers. At this time, only a single manager can be supplied.

Array<string>
<= 10 items
team_managers

The slugs of the teams to set as the campaign managers.

Array<string>
<= 10 items
ends_at

The end date and time of the campaign. The date must be in the future.

string format: date-time
contact_link

The contact link of the campaign. Must be a URI.

string format: uri
nullable
code_scanning_alerts
required

The code scanning alerts to include in this campaign

Array<object>
nullable >= 1 items
object
repository_id
required

The repository id

integer
alert_numbers
required

The alert numbers

Array<integer>
>= 1 items
generate_issues

If true, will automatically generate issues for the campaign. The default is false.

boolean
Examples
Example default
{
"name": "Critical CodeQL alerts",
"description": "Address critical alerts before they are exploited to prevent breaches, protect sensitive data, and mitigate financial and reputational damage.",
"managers": [
"octocat"
],
"ends_at": "2024-03-14T00:00:00Z",
"code_scanning_alerts": [
{
"repository_id": 1296269,
"alert_numbers": [
1,
2
]
}
]
}

Response

Media type application/json
Campaign summary

The campaign metadata and alert stats.

object
number
required

The number of the newly created campaign

integer
created_at
required

The date and time the campaign was created, in ISO 8601 format’:’ YYYY-MM-DDTHH:MM:SSZ.

string format: date-time
updated_at
required

The date and time the campaign was last updated, in ISO 8601 format’:’ YYYY-MM-DDTHH:MM:SSZ.

string format: date-time
name

The campaign name

string
description
required

The campaign description

string
managers
required

The campaign managers

Array<object>
Simple User

A GitHub user.

object
name
string
nullable
email
string
nullable
login
required
string
id
required
integer format: int64
node_id
required
string
avatar_url
required
string format: uri
gravatar_id
required
string
nullable
url
required
string format: uri
html_url
required
string format: uri
followers_url
required
string format: uri
following_url
required
string
gists_url
required
string
starred_url
required
string
subscriptions_url
required
string format: uri
organizations_url
required
string format: uri
repos_url
required
string format: uri
events_url
required
string
received_events_url
required
string format: uri
type
required
string
site_admin
required
boolean
starred_at
string
user_view_type
string
team_managers

The campaign team managers

Array<object>
Team

Groups of organization members that gives permissions on specified repositories.

object
id
required
integer
node_id
required
string
name
required
string
slug
required
string
description
required
string
nullable
privacy
string
notification_setting
string
permission
required
string
permissions
object
pull
required
boolean
triage
required
boolean
push
required
boolean
maintain
required
boolean
admin
required
boolean
url
required
string format: uri
html_url
required
string format: uri
members_url
required
string
repositories_url
required
string format: uri
type
required

The ownership type of the team

string
Allowed values: enterprise organization
access_source

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.

string
Allowed values: direct organization enterprise
organization_id

Unique identifier of the organization to which this team belongs

integer
enterprise_id

Unique identifier of the enterprise to which this team belongs

integer
parent
required
Team Simple

Groups of organization members that gives permissions on specified repositories.

object
id
required

Unique identifier of the team

integer
node_id
required
string
url
required

URL for the team

string format: uri
members_url
required
string
name
required

Name of the team

string
description
required

Description of the team

string
nullable
permission
required

Permission that the team will have for its repositories

string
privacy

The level of privacy this team should have

string
notification_setting

The notification setting the team has set

string
html_url
required
string format: uri
repositories_url
required
string format: uri
slug
required
string
ldap_dn

Distinguished Name (DN) that team maps to within LDAP environment

string
type
required

The ownership type of the team

string
Allowed values: enterprise organization
organization_id

Unique identifier of the organization to which this team belongs

integer
enterprise_id

Unique identifier of the enterprise to which this team belongs

integer
published_at

The date and time the campaign was published, in ISO 8601 format’:’ YYYY-MM-DDTHH:MM:SSZ.

string format: date-time
ends_at
required

The date and time the campaign has ended, in ISO 8601 format’:’ YYYY-MM-DDTHH:MM:SSZ.

string format: date-time
closed_at

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.

string format: date-time
nullable
state
required
Campaign state

Indicates whether a campaign is open or closed

string
Allowed values: open closed
contact_link
required

The contact link of the campaign.

string format: uri
nullable
alert_stats
object
open_count
required

The number of open alerts

integer
closed_count
required

The number of closed alerts

integer
in_progress_count
required

The number of in-progress alerts

integer
Examples
Example default
{
"number": 3,
"created_at": "2024-02-14T12:29:18Z",
"updated_at": "2024-02-14T12:29:18Z",
"name": "Critical CodeQL alert",
"description": "Address critical alerts before they are exploited to prevent breaches, protect sensitive data, and mitigate financial and reputational damage.",
"managers": [
{
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
}
],
"published_at": "2024-02-14T12:29:18Z",
"ends_at": "2024-03-14T12:29:18Z",
"closed_at": null,
"state": "open",
"alert_stats": {
"open_count": 10,
"closed_count": 3,
"in_progress_count": 3
}
}

Bad Request

Media type application/json
Basic Error

Basic Error

object
message
string
documentation_url
string
url
string
status
string
Example generated
{
"message": "example",
"documentation_url": "example",
"url": "example",
"status": "example"
}

Resource not found

Media type application/json
Basic Error

Basic Error

object
message
string
documentation_url
string
url
string
status
string
Example generated
{
"message": "example",
"documentation_url": "example",
"url": "example",
"status": "example"
}

Unprocessable Entity

Media type application/json
Basic Error

Basic Error

object
message
string
documentation_url
string
url
string
status
string
Example generated
{
"message": "example",
"documentation_url": "example",
"url": "example",
"status": "example"
}

Too Many Requests

Service unavailable

Media type application/json
object
code
string
message
string
documentation_url
string
Example generated
{
"code": "example",
"message": "example",
"documentation_url": "example"
}