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.
Call through Alter
Section titled “Call through Alter”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 osfrom alter_sdk import Appfrom 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()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
path | object | Required within parent | Additional keys: not allowed |
path.org | string | Required within parent | |
body | object | Required within parent | Additional keys: not allowed |
body.code_scanning_alerts | JSON | Optional | |
body.code_scanning_alerts (anyOf 1) | array | Alternative | The code scanning alerts to include in this campaign Minimum items: 1 |
body.code_scanning_alerts (anyOf 1)[] | object | Each item | Additional keys: not allowed |
body.code_scanning_alerts (anyOf 1)[].alert_numbers | array | Required within parent | The alert numbers Minimum items: 1 |
body.code_scanning_alerts (anyOf 1)[].alert_numbers[] | integer | Each item | |
body.code_scanning_alerts (anyOf 1)[].repository_id | integer | Required within parent | The repository id |
body.code_scanning_alerts (anyOf 2) | null | Alternative | |
body.contact_link | JSON | Optional | |
body.contact_link (anyOf 1) | string | Alternative | The contact link of the campaign. Must be a URI. Format: uri |
body.contact_link (anyOf 2) | null | Alternative | |
body.description | string | Required within parent | A description for the campaign Maximum length: 255 Minimum length: 1 |
body.ends_at | string | Required within parent | The end date and time of the campaign. The date must be in the future. Format: date-time |
body.generate_issues | boolean | Optional | If true, will automatically generate issues for the campaign. The default is false. Default: false |
body.managers | array | Optional | The 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[] | string | Each item | The login of each manager |
body.name | string | Required within parent | The name of the campaign Maximum length: 50 Minimum length: 1 |
body.team_managers | array | Optional | The slugs of the teams to set as the campaign managers. Maximum items: 10 |
body.team_managers[] | string | Each item | The slug of each team |
body (oneOf 1) | JSON | Alternative | |
body (oneOf 2) | JSON | Alternative |
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | Model | Root | Expand Update a campaign — response body |
Referenced models: Update a campaign — response body
Schemas
Section titled “Schemas”1 more schema is linked from the tables above, on the schema pages.
Update a campaign — response body
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | The campaign metadata and alert stats. |
alert_stats | object | Optional | Additional keys: not allowed |
alert_stats.closed_count | JSON | Required within parent | |
alert_stats.closed_count (anyOf 1) | integer | Alternative | The number of closed alerts |
alert_stats.closed_count (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
alert_stats.in_progress_count | JSON | Required within parent | |
alert_stats.in_progress_count (anyOf 1) | integer | Alternative | The number of in-progress alerts |
alert_stats.in_progress_count (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
alert_stats.open_count | JSON | Required within parent | |
alert_stats.open_count (anyOf 1) | integer | Alternative | The number of open alerts |
alert_stats.open_count (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
closed_at | JSON | Optional | |
closed_at (anyOf 1) | string | Alternative | 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. Format: date-time |
closed_at (anyOf 2) | null | Alternative | |
contact_link | JSON | Required within parent | |
contact_link (anyOf 1) | string | Alternative | The contact link of the campaign. Format: uri |
contact_link (anyOf 2) | null | Alternative | |
created_at | string | Required within parent | The date and time the campaign was created, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ. Format: date-time |
description | string | Required within parent | The campaign description |
ends_at | string | Required within parent | The date and time the campaign has ended, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ. Format: date-time |
managers | array | Required within parent | The campaign managers |
managers[] | Model | Each item | Expand List users — response body — item |
name | string | Optional | The campaign name |
number | JSON | Required within parent | |
number (anyOf 1) | integer | Alternative | The number of the newly created campaign |
number (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
published_at | string | Optional | The date and time the campaign was published, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ. Format: date-time |
state | string | Required within parent | Indicates whether a campaign is open or closed Known values: open, closed |
team_managers | array | Optional | The campaign team managers |
team_managers[] | Model | Each item | Expand List teams — response body — item |
updated_at | string | Required within parent | The 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
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | A GitHub user. |
avatar_url | string | Required within parent | Format: uri |
email | JSON | Optional | |
email (anyOf 1) | string | Alternative | |
email (anyOf 2) | null | Alternative | |
events_url | string | Required within parent | |
followers_url | string | Required within parent | Format: uri |
following_url | string | Required within parent | |
gists_url | string | Required within parent | |
gravatar_id | JSON | Required within parent | |
gravatar_id (anyOf 1) | string | Alternative | |
gravatar_id (anyOf 2) | null | Alternative | |
html_url | string | Required within parent | Format: uri |
id | JSON | Required within parent | |
id (anyOf 1) | integer | Alternative | Format: int64 |
id (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
login | string | Required within parent | |
name | JSON | Optional | |
name (anyOf 1) | string | Alternative | |
name (anyOf 2) | null | Alternative | |
node_id | string | Required within parent | |
organizations_url | string | Required within parent | Format: uri |
received_events_url | string | Required within parent | Format: uri |
repos_url | string | Required within parent | Format: uri |
site_admin | boolean | Required within parent | |
starred_at | string | Optional | |
starred_url | string | Required within parent | |
subscriptions_url | string | Required within parent | Format: uri |
type | string | Required within parent | |
url | string | Required within parent | Format: uri |
user_view_type | string | Optional |
List teams — response body — item
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Groups of organization members that gives permissions on specified repositories. |
access_source | string | Optional | 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`. Known values: direct, organization, enterprise |
description | JSON | Required within parent | |
description (anyOf 1) | string | Alternative | |
description (anyOf 2) | null | Alternative | |
enterprise_id | JSON | Optional | |
enterprise_id (anyOf 1) | integer | Alternative | Unique identifier of the enterprise to which this team belongs |
enterprise_id (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
html_url | string | Required within parent | Format: uri |
id | JSON | Required within parent | |
id (anyOf 1) | integer | Alternative | |
id (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
members_url | string | Required within parent | |
name | string | Required within parent | |
node_id | string | Required within parent | |
notification_setting | string | Optional | |
organization_id | JSON | Optional | |
organization_id (anyOf 1) | integer | Alternative | Unique identifier of the organization to which this team belongs |
organization_id (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
parent | Model | Required within parent | Expand Create a team — response body — parent |
permission | string | Required within parent | |
permissions | object | Optional | |
permissions.admin | boolean | Required within parent | |
permissions.maintain | boolean | Required within parent | |
permissions.pull | boolean | Required within parent | |
permissions.push | boolean | Required within parent | |
permissions.triage | boolean | Required within parent | |
privacy | string | Optional | |
repositories_url | string | Required within parent | Format: uri |
slug | string | Required within parent | |
type | string | Required within parent | The ownership type of the team Known values: enterprise, organization |
url | string | Required within parent | Format: uri |
Referenced models: Create a team — response body — parent
Create a team — response body — parent
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | JSON | Root | |
$ (anyOf 1) | Model | Alternative | Expand Create a team — response body — parent / type: enterprise, organization |
$ (anyOf 2) | null | Alternative |
Referenced models: Create a team — response body — parent / type: enterprise, organization
Policy, approvals and errors
Section titled “Policy, approvals and errors”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"}