# API reference

> Every endpoint of the Git API, its authentication and its errors.

Applies to: Sypnia Cloud (paid service).  
Source: https://git.docs.sypnia.com/api/

For agents: Base https://git.api.sypnia.com/v1, shaped like GitHub's REST API where equivalent. Auth Bearer: Sypnia token or syp_git_ token. Resources: repos, branches + protection, contents, commits, statuses, pulls (+ reviews, merge), issues (+ comments, cases), keys, deploy-keys, hooks, imports/exports/mirrors. Errors {error:{code,message}}: 401, 403 forbidden/protected_branch, 404, 409 conflict, 422 invalid_request, 429 rate_limited.

**Base address:** `https://git.api.sypnia.com/v1`. **Authentication:** `Authorization: Bearer <token>`, a Sypnia token or an [HTTPS token](https://git.docs.sypnia.com/access/https-tokens). Paths and payloads follow GitHub's REST API wherever there is an equivalent.

## Repositories and code

### Get a repository

`GET /v1/repos/{owner}/{repo}` \[Cloud]

**Authentication:** repo:read

### Create a repository`POST /v1/orgs/{org}/repos` \[Cloud]`{ name, visibility }`.**Authentication:** repo:admin
### A file or a folder`GET /v1/repos/{owner}/{repo}/contents/{path}` \[Cloud]`?ref=`.**Authentication:** repo:read

### Branches

`GET /v1/repos/{owner}/{repo}/branches` \[Cloud]

**Authentication:** repo:read

### Protect a branch`PUT /v1/repos/{owner}/{repo}/branches/{branch}/protection` \[Cloud][The rules](https://git.docs.sypnia.com/repos/branches-and-protection).**Authentication:** repo:maintain
### Report a check`POST /v1/repos/{owner}/{repo}/statuses/{sha}` \[Cloud]`{ state, context, target_url?, description? }`.**Authentication:** repo:write

## Pull requests and issues

### Open a pull request`POST /v1/repos/{owner}/{repo}/pulls` \[Cloud]`{ head, base, title, body, draft? }`.**Authentication:** repo:write
### Review`POST /v1/repos/{owner}/{repo}/pulls/{n}/reviews` \[Cloud]`{ event: "APPROVE" | "REQUEST_CHANGES" | "COMMENT", body, comments? }`.**Authentication:** repo:write
### Merge`PUT /v1/repos/{owner}/{repo}/pulls/{n}/merge` \[Cloud]`{ method: "merge" | "squash" | "rebase" }`. `403 protected_branch` when the rules are not met.**Authentication:** repo:write
### Open an issue`POST /v1/repos/{owner}/{repo}/issues` \[Cloud]`{ title, body, labels?, cases? }`.**Authentication:** repo:triage
### Link use cases`PUT /v1/repos/{owner}/{repo}/issues/{n}/cases` \[Cloud]`{ cases: ["place-order"] }`.**Authentication:** repo:triage
### History of a case`GET /v1/repos/{owner}/{repo}/commits?case={id}` \[Engine, Cloud]The commits whose `Case:` trailer names the case, newest first, each with its pull request and whether it is on the default branch; `since` and `until` narrow the range.**Authentication:** repo:read

## Access, hooks and moves

### Add an SSH key

`POST /v1/user/keys` \[Cloud]

**Authentication:** user

### Add a deploy key`POST /v1/repos/{owner}/{repo}/keys` \[Cloud]`{ key, read_only }`.**Authentication:** repo:admin
### Create a webhook`POST /v1/repos/{owner}/{repo}/hooks` \[Cloud]`{ url, secret, events }`.**Authentication:** repo:maintain
### Import from GitHub`POST /v1/imports` \[Cloud]`{ source: "github", repository }`; follow with `GET /v1/imports/{id}`.**Authentication:** repo:admin
### Set up a mirror`POST /v1/repos/{owner}/{repo}/mirrors` \[Cloud]`{ target: "github", repository }`: a read-only copy on GitHub, updated on every push. `DELETE` on the same path stops it.**Authentication:** repo:admin

## Errors

| Status | Code                            | When                                                 |
| ------ | ------------------------------- | ---------------------------------------------------- |
| 401    | `unauthorized`                  | no token, or an expired one                          |
| 403    | `forbidden`, `protected_branch` | your role does not allow it; a branch rule blocks it |
| 404    | `not_found`                     | it does not exist, or you cannot see it              |
| 409    | `conflict`                      | the branch moved; merge conflicts                    |
| 422    | `invalid_request`               | a field is missing or wrong                          |
| 429    | `rate_limited`                  | too many requests                                    |
