Open a code workspace
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, fromGET /repos, with an optionalref: a branch, tag, or commit. Withoutref, 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.
| Field | Description |
|---|---|
repository_idstring (uuid) | Id from the repository list. Give this, or pull_request_url. |
pull_request_urlstring | A pull or merge request’s web link: the workspace opens at its head commit and can diff against its base. |
refstring | Branch, tag or commit to open with repository_id; the default branch when left out. |
Responses
200 OK
| Field | Description |
|---|---|
workspace_idstring, required | Pass to the code query endpoint. |
repository_idstring (uuid), required | |
repositorystring, required | |
commit_shastring, required | The commit the workspace reads. |
base_commit_shastring, required, nullable | The pull request’s base commit, which diff compares against; null outside a pull request. |
pull_request_numbernumber, required, nullable | |
statestring, required | preparing while the code is checked out; queries wait for it. One of preparing, ready, failed, or closed. |
errorstring, 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.