Skip to content

GitHub: Create a campaign for an organization

GitHub campaigns.campaignsCreateCampaign: arguments, response, policy and SDK examples.

← Campaigns operations · Get started

Operation github.campaigns_create_campaign

Provider route: POST /orgs/{org}/campaigns. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/github with npm, or alter-sdk-github with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { GitHubIntegration } from "@alter-ai/github";
async function execute(input: Parameters<GitHubIntegration["campaigns"]["campaignsCreateCampaign"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new GitHubIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.campaigns.campaignsCreateCampaign(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_github import GitHubIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = GitHubIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.campaigns.campaigns_create_campaign(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
pathobjectRequired within parentAdditional keys: not allowed
path.orgstringRequired within parent
bodyobjectRequired within parentAdditional keys: not allowed
body.code_scanning_alertsJSONOptional
body.code_scanning_alerts (anyOf 1)arrayAlternativeThe code scanning alerts to include in this campaign
Minimum items: 1
body.code_scanning_alerts (anyOf 1)[]objectEach itemAdditional keys: not allowed
body.code_scanning_alerts (anyOf 1)[].alert_numbersarrayRequired within parentThe alert numbers
Minimum items: 1
body.code_scanning_alerts (anyOf 1)[].alert_numbers[]integerEach item
body.code_scanning_alerts (anyOf 1)[].repository_idintegerRequired within parentThe repository id
body.code_scanning_alerts (anyOf 2)nullAlternative
body.contact_linkJSONOptional
body.contact_link (anyOf 1)stringAlternativeThe contact link of the campaign. Must be a URI.
Format: uri
body.contact_link (anyOf 2)nullAlternative
body.descriptionstringRequired within parentA description for the campaign
Maximum length: 255
Minimum length: 1
body.ends_atstringRequired within parentThe end date and time of the campaign. The date must be in the future.
Format: date-time
body.generate_issuesbooleanOptionalIf true, will automatically generate issues for the campaign. The default is false.
Default: false
body.managersarrayOptionalThe logins of the users to set as the campaign managers. At this time, only a single manager can be supplied.
Maximum items: 10
body.managers[]stringEach itemThe login of each manager
body.namestringRequired within parentThe name of the campaign
Maximum length: 50
Minimum length: 1
body.team_managersarrayOptionalThe slugs of the teams to set as the campaign managers.
Maximum items: 10
body.team_managers[]stringEach itemThe slug of each team
body (oneOf 1)JSONAlternative
body (oneOf 2)JSONAlternative

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$ModelRootExpand Update a campaign — response body

Referenced models: Update a campaign — response body

1 more schema is linked from the tables above, on the schema pages.

Update a campaign — response body
FieldTypePresenceDescription and constraints
$objectRootThe campaign metadata and alert stats.
alert_statsobjectOptionalAdditional keys: not allowed
alert_stats.closed_countJSONRequired within parent
alert_stats.closed_count (anyOf 1)integerAlternativeThe number of closed alerts
alert_stats.closed_count (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
alert_stats.in_progress_countJSONRequired within parent
alert_stats.in_progress_count (anyOf 1)integerAlternativeThe number of in-progress alerts
alert_stats.in_progress_count (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
alert_stats.open_countJSONRequired within parent
alert_stats.open_count (anyOf 1)integerAlternativeThe number of open alerts
alert_stats.open_count (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
closed_atJSONOptional
closed_at (anyOf 1)stringAlternativeThe 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.
Format: date-time
closed_at (anyOf 2)nullAlternative
contact_linkJSONRequired within parent
contact_link (anyOf 1)stringAlternativeThe contact link of the campaign.
Format: uri
contact_link (anyOf 2)nullAlternative
created_atstringRequired within parentThe date and time the campaign was created, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
Format: date-time
descriptionstringRequired within parentThe campaign description
ends_atstringRequired within parentThe date and time the campaign has ended, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
Format: date-time
managersarrayRequired within parentThe campaign managers
managers[]ModelEach itemExpand List users — response body — item
namestringOptionalThe campaign name
numberJSONRequired within parent
number (anyOf 1)integerAlternativeThe number of the newly created campaign
number (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
published_atstringOptionalThe date and time the campaign was published, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
Format: date-time
statestringRequired within parentIndicates whether a campaign is open or closed
Known values: open, closed
team_managersarrayOptionalThe campaign team managers
team_managers[]ModelEach itemExpand List teams — response body — item
updated_atstringRequired within parentThe date and time the campaign was last updated, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
Format: date-time

Referenced models: List users — response body — item, List teams — response body — item

List users — response body — item
FieldTypePresenceDescription and constraints
$objectRootA GitHub user.
avatar_urlstringRequired within parentFormat: uri
emailJSONOptional
email (anyOf 1)stringAlternative
email (anyOf 2)nullAlternative
events_urlstringRequired within parent
followers_urlstringRequired within parentFormat: uri
following_urlstringRequired within parent
gists_urlstringRequired within parent
gravatar_idJSONRequired within parent
gravatar_id (anyOf 1)stringAlternative
gravatar_id (anyOf 2)nullAlternative
html_urlstringRequired within parentFormat: uri
idJSONRequired within parent
id (anyOf 1)integerAlternativeFormat: int64
id (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
loginstringRequired within parent
nameJSONOptional
name (anyOf 1)stringAlternative
name (anyOf 2)nullAlternative
node_idstringRequired within parent
organizations_urlstringRequired within parentFormat: uri
received_events_urlstringRequired within parentFormat: uri
repos_urlstringRequired within parentFormat: uri
site_adminbooleanRequired within parent
starred_atstringOptional
starred_urlstringRequired within parent
subscriptions_urlstringRequired within parentFormat: uri
typestringRequired within parent
urlstringRequired within parentFormat: uri
user_view_typestringOptional
List teams — response body — item
FieldTypePresenceDescription and constraints
$objectRootGroups of organization members that gives permissions on specified repositories.
access_sourcestringOptionalHow 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`.
Known values: direct, organization, enterprise
descriptionJSONRequired within parent
description (anyOf 1)stringAlternative
description (anyOf 2)nullAlternative
enterprise_idJSONOptional
enterprise_id (anyOf 1)integerAlternativeUnique identifier of the enterprise to which this team belongs
enterprise_id (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
html_urlstringRequired within parentFormat: uri
idJSONRequired within parent
id (anyOf 1)integerAlternative
id (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
members_urlstringRequired within parent
namestringRequired within parent
node_idstringRequired within parent
notification_settingstringOptional
organization_idJSONOptional
organization_id (anyOf 1)integerAlternativeUnique identifier of the organization to which this team belongs
organization_id (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
parentModelRequired within parentExpand Create a team — response body — parent
permissionstringRequired within parent
permissionsobjectOptional
permissions.adminbooleanRequired within parent
permissions.maintainbooleanRequired within parent
permissions.pullbooleanRequired within parent
permissions.pushbooleanRequired within parent
permissions.triagebooleanRequired within parent
privacystringOptional
repositories_urlstringRequired within parentFormat: uri
slugstringRequired within parent
typestringRequired within parentThe ownership type of the team
Known values: enterprise, organization
urlstringRequired within parentFormat: uri

Referenced models: Create a team — response body — parent

Create a team — response body — parent
FieldTypePresenceDescription and constraints
$JSONRoot
$ (anyOf 1)ModelAlternativeExpand Create a team — response body — parent / type: enterprise, organization
$ (anyOf 2)nullAlternative

Referenced models: Create a team — response body — parent / type: enterprise, organization

SDK function policy ID: github.campaigns_create_campaign. Catalog operation: campaigns/create-campaign. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Pinned headers: {"X-GitHub-Api-Version": "2026-03-10", "User-Agent": "Alter", "Accept": "application/vnd.github+json"}

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand which product and documentation features are useful.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

You can change these choices at any time from Cookie settings.