Skip to main content

org_campaigns

Creates, updates, deletes, gets or lists an org_campaigns resource.

Overview

Nameorg_campaigns
TypeResource
Idgithub.campaigns.org_campaigns

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
namestringThe campaign name
alert_statsobject
closed_atstring (date-time)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.
contact_linkstring (uri)The contact link of the campaign.
created_atstring (date-time)The date and time the campaign was created, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
descriptionstringThe campaign description
ends_atstring (date-time)The date and time the campaign has ended, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
managersarrayThe campaign managers
numberintegerThe number of the newly created campaign
published_atstring (date-time)The date and time the campaign was published, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
statestringIndicates whether a campaign is open or closed (open, closed) (title: Campaign state)
team_managersarrayThe campaign team managers
updated_atstring (date-time)The date and time the campaign was last updated, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_campaign_summaryselectorg, campaign_numberGets 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.
list_org_campaignsselectorgpage, per_page, direction, state, sortLists campaigns in 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.
create_campaigninsertorg, name, description, ends_at, code_scanning_alerts, secret_scanning_alertsCreate 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.
update_campaignupdateorg, campaign_numberUpdates a campaign in 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.
delete_campaigndeleteorg, campaign_numberDeletes a campaign in 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.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
campaign_numberintegerThe campaign number.
orgstringThe organization name. The name is not case sensitive.
directionstringThe direction to sort the results by.
pageintegerThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pageintegerThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
sortstringThe property by which to sort the results.
statestringIf specified, only campaigns with this state will be returned.

SELECT examples

Gets 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.

SELECT
name,
alert_stats,
closed_at,
contact_link,
created_at,
description,
ends_at,
managers,
number,
published_at,
state,
team_managers,
updated_at
FROM github.campaigns.org_campaigns
WHERE org = '{{ org }}' -- required
AND campaign_number = '{{ campaign_number }}' -- required
;

INSERT examples

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.

INSERT INTO github.campaigns.org_campaigns (
name,
description,
managers,
team_managers,
ends_at,
contact_link,
code_scanning_alerts,
generate_issues,
org
)
SELECT
'{{ name }}' /* required */,
'{{ description }}' /* required */,
'{{ managers }}',
'{{ team_managers }}',
'{{ ends_at }}' /* required */,
'{{ contact_link }}',
'{{ code_scanning_alerts }}' /* required */,
{{ generate_issues }},
'{{ org }}'
RETURNING
name,
alert_stats,
closed_at,
contact_link,
created_at,
description,
ends_at,
managers,
number,
published_at,
state,
team_managers,
updated_at
;

UPDATE examples

Updates a campaign in 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.

UPDATE github.campaigns.org_campaigns
SET
name = '{{ name }}',
description = '{{ description }}',
managers = '{{ managers }}',
team_managers = '{{ team_managers }}',
ends_at = '{{ ends_at }}',
contact_link = '{{ contact_link }}',
state = '{{ state }}'
WHERE
org = '{{ org }}' --required
AND campaign_number = '{{ campaign_number }}' --required
RETURNING
name,
alert_stats,
closed_at,
contact_link,
created_at,
description,
ends_at,
managers,
number,
published_at,
state,
team_managers,
updated_at;

DELETE examples

Deletes a campaign in 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.

DELETE FROM github.campaigns.org_campaigns
WHERE org = '{{ org }}' --required
AND campaign_number = '{{ campaign_number }}' --required
;