---
title: "Create repository context"
method: POST
path: "/api/v2/contexts/create"
tags: ["Repository Context"]
---

# Create repository context

`POST /api/v2/contexts/create`

## Request

- Base URL: `https://zeropath.com`
- URL: `https://zeropath.com/api/v2/contexts/create`
- Auth: API key in header `X-ZeroPath-API-Token-Id` and API key in header `X-ZeroPath-API-Token-Secret`

Create context for subsequent scans. Defaults to all repositories; repositoryIds selects repositories, and tagIds alone selects tags. Requires the context save permission across the target scope.

## Request body

- CreateContextInput
  - `organizationId` string: Organization ID. Resolved from authentication when omitted.
  - `title` string: Optional label. Empty or whitespace-only titles clear the label.
  - `context` string, required: Nonblank natural-language context used in subsequent scans.
  - `globPattern` string: File glob. Defaults to ** on creation; omission preserves the value on update.
  - `applicableSourceTypes` string[]: Source types to target. An empty array applies to all source types.
  - `scanPhases` string[]: Scan phases to target. Omission preserves phases on update; creation uses the documented default phase set.
  - `scope` 'allRepositories' | 'repositories' | 'tags': Explicit scope. repositories requires repositoryIds; tags requires tagIds. Conflicting selectors are rejected.
  - `allRepositories` true: Apply to every current and future repository. Cannot be combined with repositoryIds or scope: tags.
  - `repositoryIds` string[]: Direct repository assignments. Omission on update preserves scope; use allRepositories: true to change it.
  - `tagIds` string[]: Additional tag assignments. On create, tagIds alone creates tag-only scope. On update, tagIds alone replaces direct tags and preserves scanner-setting assignments; use scope: tags to switch to tag-only scope.

## Response `200`

Successful response

- ContextIdResponse
  - `id` string, required

## Other responses

- `400`: Error Response
- `401`: Error Response
- `403`: Error Response
- `404`: Error Response
- `409`: Error Response

---

[API](https://skmtc.dev/zeropath/apis/zeropath-api.md) - [All operations](https://skmtc.dev/zeropath/apis/zeropath-api/llms.txt) - [OpenAPI document](https://skmtc.dev/zeropath/apis/zeropath-api/revisions/126e9c80ba0d?raw)
