# Build API reference

Source: `@socra/build-api@0.2.0` (BuildContract).

Remote source-to-artifact builds for Socra projects.

## API surface

Base URL: `https://build.socra.cloud`

## Builds

An immutable source-to-artifact execution.

### Resource schema

- `id` custom, required
- `project_id` custom, required
- `repository` string (pattern: ^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$), required
- `ref` string (min length: 1; max length: 256), required
- `commit_sha` string | null, required
- `profile` "bun-web" | "bun-service" | "docker", required
- `root` string, required
- `name` string (min length: 1; max length: 63; pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$), required
- `status` "queued" | "running" | "succeeded" | "failed" | "cancelled", required
- `artifact_id` string | null, required
- `error` string | null, required
- `logs` string, required
- `cache_hit` boolean, required
- `created_at` custom, required
- `updated_at` custom, required
- `started_at` custom | null, required
- `finished_at` custom | null, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "repository": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$"
    },
    "ref": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "commit_sha": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "profile": {
      "type": "string",
      "enum": [
        "bun-web",
        "bun-service",
        "docker"
      ]
    },
    "root": {
      "type": "string"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 63,
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "succeeded",
        "failed",
        "cancelled"
      ]
    },
    "artifact_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "logs": {
      "type": "string"
    },
    "cache_hit": {
      "type": "boolean"
    },
    "created_at": {},
    "updated_at": {},
    "started_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "finished_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "id",
    "project_id",
    "repository",
    "ref",
    "commit_sha",
    "profile",
    "root",
    "name",
    "status",
    "artifact_id",
    "error",
    "logs",
    "cache_hit",
    "created_at",
    "updated_at",
    "started_at",
    "finished_at"
  ],
  "additionalProperties": false
}
```

### Create build

`POST /v1/builds`

#### Request body

- `project_id` custom, required
- `repository` string (pattern: ^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$), required
- `ref` string (default: "main"; min length: 1; max length: 256), optional
- `profile` "bun-web" | "bun-service" | "docker", required
- `root` string (default: "."), optional
- `name` string (min length: 1; max length: 63; pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$), required
- `source_archive` string (min length: 1), optional
- `source_digest` string (pattern: ^sha256:[0-9a-f]{64}$), optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "project_id": {},
    "repository": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$"
    },
    "ref": {
      "default": "main",
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "profile": {
      "type": "string",
      "enum": [
        "bun-web",
        "bun-service",
        "docker"
      ]
    },
    "root": {
      "default": ".",
      "type": "string"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 63,
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "source_archive": {
      "type": "string",
      "minLength": 1
    },
    "source_digest": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    }
  },
  "required": [
    "project_id",
    "repository",
    "profile",
    "name"
  ]
}
```

#### Response

- `id` custom, required
- `project_id` custom, required
- `repository` string (pattern: ^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$), required
- `ref` string (min length: 1; max length: 256), required
- `commit_sha` string | null, required
- `profile` "bun-web" | "bun-service" | "docker", required
- `root` string, required
- `name` string (min length: 1; max length: 63; pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$), required
- `status` "queued" | "running" | "succeeded" | "failed" | "cancelled", required
- `artifact_id` string | null, required
- `error` string | null, required
- `logs` string, required
- `cache_hit` boolean, required
- `created_at` custom, required
- `updated_at` custom, required
- `started_at` custom | null, required
- `finished_at` custom | null, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "repository": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$"
    },
    "ref": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "commit_sha": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "profile": {
      "type": "string",
      "enum": [
        "bun-web",
        "bun-service",
        "docker"
      ]
    },
    "root": {
      "type": "string"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 63,
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "succeeded",
        "failed",
        "cancelled"
      ]
    },
    "artifact_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "logs": {
      "type": "string"
    },
    "cache_hit": {
      "type": "boolean"
    },
    "created_at": {},
    "updated_at": {},
    "started_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "finished_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "id",
    "project_id",
    "repository",
    "ref",
    "commit_sha",
    "profile",
    "root",
    "name",
    "status",
    "artifact_id",
    "error",
    "logs",
    "cache_hit",
    "created_at",
    "updated_at",
    "started_at",
    "finished_at"
  ],
  "additionalProperties": false
}
```

### List builds

`GET /v1/builds`

#### Query parameters

- `project_id` custom, required
- `status` "queued" | "running" | "succeeded" | "failed" | "cancelled", optional
- `limit` integer (min: 1; max: 100), optional
- `after` string, optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "project_id": {},
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "succeeded",
        "failed",
        "cancelled"
      ]
    },
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "after": {
      "type": "string"
    }
  },
  "required": [
    "project_id"
  ]
}
```

#### Response

- `data` object[], required
  - `id` custom, required
  - `project_id` custom, required
  - `repository` string (pattern: ^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$), required
  - `ref` string (min length: 1; max length: 256), required
  - `commit_sha` string | null, required
  - `profile` "bun-web" | "bun-service" | "docker", required
  - `root` string, required
  - `name` string (min length: 1; max length: 63; pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$), required
  - `status` "queued" | "running" | "succeeded" | "failed" | "cancelled", required
  - `artifact_id` string | null, required
  - `error` string | null, required
  - `logs` string, required
  - `cache_hit` boolean, required
  - `created_at` custom, required
  - `updated_at` custom, required
  - `started_at` custom | null, required
  - `finished_at` custom | null, required
- `has_more` boolean, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {},
          "project_id": {},
          "repository": {
            "type": "string",
            "pattern": "^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$"
          },
          "ref": {
            "type": "string",
            "minLength": 1,
            "maxLength": 256
          },
          "commit_sha": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "profile": {
            "type": "string",
            "enum": [
              "bun-web",
              "bun-service",
              "docker"
            ]
          },
          "root": {
            "type": "string"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 63,
            "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed",
              "cancelled"
            ]
          },
          "artifact_id": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "error": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "logs": {
            "type": "string"
          },
          "cache_hit": {
            "type": "boolean"
          },
          "created_at": {},
          "updated_at": {},
          "started_at": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ]
          },
          "finished_at": {
            "anyOf": [
              {},
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "id",
          "project_id",
          "repository",
          "ref",
          "commit_sha",
          "profile",
          "root",
          "name",
          "status",
          "artifact_id",
          "error",
          "logs",
          "cache_hit",
          "created_at",
          "updated_at",
          "started_at",
          "finished_at"
        ],
        "additionalProperties": false
      }
    },
    "has_more": {
      "type": "boolean"
    }
  },
  "required": [
    "data",
    "has_more"
  ],
  "additionalProperties": false
}
```

### Get build

`GET /v1/builds/{id}`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Response

- `id` custom, required
- `project_id` custom, required
- `repository` string (pattern: ^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$), required
- `ref` string (min length: 1; max length: 256), required
- `commit_sha` string | null, required
- `profile` "bun-web" | "bun-service" | "docker", required
- `root` string, required
- `name` string (min length: 1; max length: 63; pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$), required
- `status` "queued" | "running" | "succeeded" | "failed" | "cancelled", required
- `artifact_id` string | null, required
- `error` string | null, required
- `logs` string, required
- `cache_hit` boolean, required
- `created_at` custom, required
- `updated_at` custom, required
- `started_at` custom | null, required
- `finished_at` custom | null, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "repository": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$"
    },
    "ref": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "commit_sha": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "profile": {
      "type": "string",
      "enum": [
        "bun-web",
        "bun-service",
        "docker"
      ]
    },
    "root": {
      "type": "string"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 63,
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "succeeded",
        "failed",
        "cancelled"
      ]
    },
    "artifact_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "logs": {
      "type": "string"
    },
    "cache_hit": {
      "type": "boolean"
    },
    "created_at": {},
    "updated_at": {},
    "started_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "finished_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "id",
    "project_id",
    "repository",
    "ref",
    "commit_sha",
    "profile",
    "root",
    "name",
    "status",
    "artifact_id",
    "error",
    "logs",
    "cache_hit",
    "created_at",
    "updated_at",
    "started_at",
    "finished_at"
  ],
  "additionalProperties": false
}
```

### Cancel build

`POST /v1/builds/{id}/cancel`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Response

- `id` custom, required
- `project_id` custom, required
- `repository` string (pattern: ^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$), required
- `ref` string (min length: 1; max length: 256), required
- `commit_sha` string | null, required
- `profile` "bun-web" | "bun-service" | "docker", required
- `root` string, required
- `name` string (min length: 1; max length: 63; pattern: ^[a-z0-9]+(?:-[a-z0-9]+)*$), required
- `status` "queued" | "running" | "succeeded" | "failed" | "cancelled", required
- `artifact_id` string | null, required
- `error` string | null, required
- `logs` string, required
- `cache_hit` boolean, required
- `created_at` custom, required
- `updated_at` custom, required
- `started_at` custom | null, required
- `finished_at` custom | null, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "repository": {
      "type": "string",
      "pattern": "^[A-Za-z0-9_.-]+\\/[A-Za-z0-9_.-]+$"
    },
    "ref": {
      "type": "string",
      "minLength": 1,
      "maxLength": 256
    },
    "commit_sha": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "profile": {
      "type": "string",
      "enum": [
        "bun-web",
        "bun-service",
        "docker"
      ]
    },
    "root": {
      "type": "string"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 63,
      "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
    },
    "status": {
      "type": "string",
      "enum": [
        "queued",
        "running",
        "succeeded",
        "failed",
        "cancelled"
      ]
    },
    "artifact_id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "error": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    },
    "logs": {
      "type": "string"
    },
    "cache_hit": {
      "type": "boolean"
    },
    "created_at": {},
    "updated_at": {},
    "started_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "finished_at": {
      "anyOf": [
        {},
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "id",
    "project_id",
    "repository",
    "ref",
    "commit_sha",
    "profile",
    "root",
    "name",
    "status",
    "artifact_id",
    "error",
    "logs",
    "cache_hit",
    "created_at",
    "updated_at",
    "started_at",
    "finished_at"
  ],
  "additionalProperties": false
}
```

## Artifacts

A content-addressed OCI image produced by a build.

### Resource schema

- `id` custom, required
- `project_id` custom, required
- `build_id` custom, required
- `name` string, required
- `image` string (pattern: ^[a-z0-9.-]+(?::[0-9]+)?\/[a-z0-9._/-]+@sha256:[0-9a-f]{64}$), required
- `digest` string (pattern: ^sha256:[0-9a-f]{64}$), required
- `created_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "build_id": {},
    "name": {
      "type": "string"
    },
    "image": {
      "type": "string",
      "pattern": "^[a-z0-9.-]+(?::[0-9]+)?\\/[a-z0-9._/-]+@sha256:[0-9a-f]{64}$"
    },
    "digest": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "created_at": {}
  },
  "required": [
    "id",
    "project_id",
    "build_id",
    "name",
    "image",
    "digest",
    "created_at"
  ],
  "additionalProperties": false
}
```

### List artifacts

`GET /v1/artifacts`

#### Query parameters

- `project_id` custom, required
- `build_id` custom, optional
- `limit` integer (min: 1; max: 100), optional
- `after` string, optional

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "project_id": {},
    "build_id": {},
    "limit": {
      "type": "integer",
      "minimum": 1,
      "maximum": 100
    },
    "after": {
      "type": "string"
    }
  },
  "required": [
    "project_id"
  ]
}
```

#### Response

- `data` object[], required
  - `id` custom, required
  - `project_id` custom, required
  - `build_id` custom, required
  - `name` string, required
  - `image` string (pattern: ^[a-z0-9.-]+(?::[0-9]+)?\/[a-z0-9._/-]+@sha256:[0-9a-f]{64}$), required
  - `digest` string (pattern: ^sha256:[0-9a-f]{64}$), required
  - `created_at` custom, required
- `has_more` boolean, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {},
          "project_id": {},
          "build_id": {},
          "name": {
            "type": "string"
          },
          "image": {
            "type": "string",
            "pattern": "^[a-z0-9.-]+(?::[0-9]+)?\\/[a-z0-9._/-]+@sha256:[0-9a-f]{64}$"
          },
          "digest": {
            "type": "string",
            "pattern": "^sha256:[0-9a-f]{64}$"
          },
          "created_at": {}
        },
        "required": [
          "id",
          "project_id",
          "build_id",
          "name",
          "image",
          "digest",
          "created_at"
        ],
        "additionalProperties": false
      }
    },
    "has_more": {
      "type": "boolean"
    }
  },
  "required": [
    "data",
    "has_more"
  ],
  "additionalProperties": false
}
```

### Get artifact

`GET /v1/artifacts/{id}`

#### Path parameters

- `id` custom, required

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema"
}
```


#### Response

- `id` custom, required
- `project_id` custom, required
- `build_id` custom, required
- `name` string, required
- `image` string (pattern: ^[a-z0-9.-]+(?::[0-9]+)?\/[a-z0-9._/-]+@sha256:[0-9a-f]{64}$), required
- `digest` string (pattern: ^sha256:[0-9a-f]{64}$), required
- `created_at` custom, required

JSON Schema:

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {},
    "project_id": {},
    "build_id": {},
    "name": {
      "type": "string"
    },
    "image": {
      "type": "string",
      "pattern": "^[a-z0-9.-]+(?::[0-9]+)?\\/[a-z0-9._/-]+@sha256:[0-9a-f]{64}$"
    },
    "digest": {
      "type": "string",
      "pattern": "^sha256:[0-9a-f]{64}$"
    },
    "created_at": {}
  },
  "required": [
    "id",
    "project_id",
    "build_id",
    "name",
    "image",
    "digest",
    "created_at"
  ],
  "additionalProperties": false
}
```

---

Company: Socra — Multiply Your Judgment
Canonical URL: https://cloud.socra.com/docs/build/reference/api
