Skip to content

GitHub: Create a Code QL variant analysis

GitHub codeScanning.codeScanningCreateVariantAnalysis: arguments, response, policy and SDK examples.

← Code scanning operations · Get started

Operation github.code_scanning_create_variant_analysis

Provider route: POST /repos/{owner}/{repo}/code-scanning/codeql/variant-analyses. 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["codeScanning"]["codeScanningCreateVariantAnalysis"]>[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.codeScanning.codeScanningCreateVariantAnalysis(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.code_scanning.code_scanning_create_variant_analysis(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
pathobjectRequired within parentAdditional keys: not allowed
path.ownerstringRequired within parent
path.repostringRequired within parent
bodyobjectRequired within parentAdditional keys: not allowed
body.languagestringRequired within parentThe language targeted by the CodeQL query
One of: actions, cpp, csharp, go, java, javascript, python, ruby, rust, swift
body.query_packstringRequired within parentA Base64-encoded tarball containing a CodeQL query and all its dependencies
body.repositoriesarrayOptionalList of repository names (in the form `owner/repo-name`) to run the query against. Precisely one property from `repositories`, `repository_lists` and `repository_owners` is required.
body.repositories[]stringEach item
body.repository_listsarrayOptionalList of repository lists to run the query against. Precisely one property from `repositories`, `repository_lists` and `repository_owners` is required.
Maximum items: 1
body.repository_lists[]stringEach item
body.repository_ownersarrayOptionalList of organization or user names whose repositories the query should be run against. Precisely one property from `repositories`, `repository_lists` and `repository_owners` is required.
Maximum items: 1
body.repository_owners[]stringEach item
body (oneOf 1)JSONAlternative
body (oneOf 2)JSONAlternative
body (oneOf 3)JSONAlternative

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

FieldTypePresenceDescription and constraints
$ModelRootExpand Create a Code QL variant analysis — response body

Referenced models: Create a Code QL variant analysis — response body

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

Create a Code QL variant analysis — response body
FieldTypePresenceDescription and constraints
$objectRootA run of a CodeQL query against one or more repositories.
actions_workflow_run_idJSONOptional
actions_workflow_run_id (anyOf 1)integerAlternativeThe GitHub Actions workflow run used to execute this variant analysis. This is only available if the workflow run has started.
actions_workflow_run_id (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
actorModelRequired within parentExpand List users — response body — item
completed_atJSONOptional
completed_at (anyOf 1)stringAlternativeThe date and time at which the variant analysis was completed, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ. Will be null if the variant analysis has not yet completed or this information is not available.
Format: date-time
completed_at (anyOf 2)nullAlternative
controller_repoModelRequired within parentExpand List repositories for a user migration — response body — item
created_atstringOptionalThe date and time at which the variant analysis was created, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
Format: date-time
failure_reasonstringOptionalThe reason for a failure of the variant analysis. This is only available if the variant analysis has failed.
Known values: no_repos_queried, actions_workflow_run_failed, internal_error
idJSONRequired within parent
id (anyOf 1)integerAlternativeThe ID of the variant analysis.
id (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
query_languagestringRequired within parentThe language targeted by the CodeQL query
Known values: actions, cpp, csharp, go, java, javascript, python, ruby, rust, swift
query_pack_urlstringRequired within parentThe download url for the query pack.
scanned_repositoriesarrayOptional
scanned_repositories[]objectEach item
scanned_repositories[].analysis_statusstringRequired within parentThe new status of the CodeQL variant analysis repository task.
Known values: pending, in_progress, succeeded, failed, canceled, timed_out
scanned_repositories[].artifact_size_in_bytesJSONOptional
scanned_repositories[].artifact_size_in_bytes (anyOf 1)integerAlternativeThe size of the artifact. This is only available for successful analyses.
scanned_repositories[].artifact_size_in_bytes (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
scanned_repositories[].failure_messagestringOptionalThe reason of the failure of this repo task. This is only available if the repository task has failed.
scanned_repositories[].repositoryModelRequired within parentExpand Create a Code QL variant analysis — response body — scanned repositories item repository
scanned_repositories[].result_countJSONOptional
scanned_repositories[].result_count (anyOf 1)integerAlternativeThe number of results in the case of a successful analysis. This is only available for successful analyses.
scanned_repositories[].result_count (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
skipped_repositoriesobjectOptionalInformation about repositories that were skipped from processing. This information is only available to the user that initiated the variant analysis.
skipped_repositories.access_mismatch_reposModelRequired within parentExpand Create a Code QL variant analysis — response body — skipped repositories over limit repos
skipped_repositories.no_codeql_db_reposModelRequired within parentExpand Create a Code QL variant analysis — response body — skipped repositories over limit repos
skipped_repositories.not_found_reposobjectRequired within parent
skipped_repositories.not_found_repos.repository_countJSONRequired within parent
skipped_repositories.not_found_repos.repository_count (anyOf 1)integerAlternativeThe total number of repositories that were skipped for this reason.
skipped_repositories.not_found_repos.repository_count (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
skipped_repositories.not_found_repos.repository_full_namesarrayRequired within parentA list of full repository names that were skipped. This list may not include all repositories that were skipped.
skipped_repositories.not_found_repos.repository_full_names[]stringEach item
skipped_repositories.over_limit_reposModelRequired within parentExpand Create a Code QL variant analysis — response body — skipped repositories over limit repos
statusstringRequired within parentKnown values: in_progress, succeeded, failed, cancelled
updated_atstringOptionalThe date and time at which the variant analysis was last updated, in ISO 8601 format':' YYYY-MM-DDTHH:MM:SSZ.
Format: date-time

Referenced models: Create a Code QL variant analysis — response body — scanned repositories item repository, Create a Code QL variant analysis — response body — skipped repositories over limit repos, List repositories for a user migration — response body — item, List users — response body — item

Create a Code QL variant analysis — response body — scanned repositories item repository
FieldTypePresenceDescription and constraints
$objectRootRepository Identifier
full_namestringRequired within parentThe full, globally unique, name of the repository.
idJSONRequired within parent
id (anyOf 1)integerAlternativeA unique identifier of the repository.
id (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
namestringRequired within parentThe name of the repository.
privatebooleanRequired within parentWhether the repository is private.
stargazers_countJSONRequired within parent
stargazers_count (anyOf 1)integerAlternative
stargazers_count (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
updated_atJSONRequired within parent
updated_at (anyOf 1)stringAlternativeFormat: date-time
updated_at (anyOf 2)nullAlternative
Create a Code QL variant analysis — response body — skipped repositories over limit repos
FieldTypePresenceDescription and constraints
$objectRoot
repositoriesarrayRequired within parentA list of repositories that were skipped. This list may not include all repositories that were skipped. This is only available when the repository was found and the user has access to it.
repositories[]ModelEach itemExpand Create a Code QL variant analysis — response body — scanned repositories item repository
repository_countJSONRequired within parent
repository_count (anyOf 1)integerAlternativeThe total number of repositories that were skipped for this reason.
repository_count (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:\.[0-9]+)?(?:[eE][+-]?[0-9]+)?$

Referenced models: Create a Code QL variant analysis — response body — scanned repositories item repository

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

SDK function policy ID: github.code_scanning_create_variant_analysis. Catalog operation: code-scanning/create-variant-analysis. 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.