OpenAI is partnering with Hacktron to find vulnerabilities in its systems. Read the announcement.

Skip to content Hacktron Sign in [S]
Hacktron Sign in [S] Customers Docs Contact Sign in

Open a code workspace

2 min
, View, ChatGPT, Claude, Perplexity, OpenAPI

Copy page

Open a code workspace

View MarkdownOpen in ChatGPTOpen in ClaudeOpen in PerplexityDownload OpenAPI

Opens a read-only code workspace: a checkout of one connected repository at one commit, which POST /code-workspaces/{workspace_id}/query searches and reads. Send one of:

  • repository_id, from GET /repos, with an optional ref: a branch, tag, or commit. Without ref, the workspace opens at the default branch.
  • pull_request_url, to open a pull or merge request’s head commit. The workspace can then diff the pull request against its base, base_commit_sha.

The repository must be enabled for Hacktron and hosted on GitHub, GitLab, or Azure DevOps. You need the member role or above.

Everyone in the organisation who opens the same commit shares one workspace with the same workspace_id. The first open of a commit can take a minute or two, with state set to preparing, and queries wait for it to finish. A workspace closes after 30 minutes without a query, and an organisation can have 25 open at once. When a query says the workspace has closed, open it again.

Request

POST /code-workspaces

Send an API key with the read scope in the X-Api-Key header.

Body

A required application/json body.

FieldDescription
repository_id
string (uuid)
Id from the repository list. Give this, or pull_request_url.
pull_request_url
string
A pull or merge request’s web link: the workspace opens at its head commit and can diff against its base.
ref
string
Branch, tag or commit to open with repository_id; the default branch when left out.

Responses

200 OK

FieldDescription
workspace_id
string, required
Pass to the code query endpoint.
repository_id
string (uuid), required
repository
string, required
commit_sha
string, required
The commit the workspace reads.
base_commit_sha
string, required, nullable
The pull request’s base commit, which diff compares against; null outside a pull request.
pull_request_number
number, required, nullable
state
string, required
preparing while the code is checked out; queries wait for it. One of preparing, ready, failed, or closed.
error
string, required, nullable
Why the workspace failed.

400 Bad Request

The repository isn’t enabled for Hacktron, or its provider has no code workspaces.

404 Not Found

The repository or pull request wasn’t found.

429 Too Many Requests

The organisation has 25 workspaces open, the most at once, or this one is busy with other queries.

503 Service Unavailable

The repository’s provider could not be read, or code workspaces aren’t responding; try again later.

[↓] [↑] [enter] to visit
Menu
[M]
Next in menu
[J]
Previous in menu
[K]
Find
[F]
Ask
[A]
Sign in
[S]
Copy page
[C]
Listen
[L]
Justification
[R]
Language
[G]
Dark mode
[D]
High contrast
[H]
Shortcuts
[I]
Close
[Esc]