Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Cloudflare platform skill covering Workers, D1, R2, KV, AI, Durable Objects, and security.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/artifacts/api.md
1# Artifacts API Reference23Use Artifacts through the **Workers binding**, the **REST control plane**, and **Git-compatible remotes**.45**Prefer retrieval** for exact request and response details. Verify current behavior at `https://developers.cloudflare.com/artifacts/` before relying on specific auth flows, route details, or generated binding types.67## Workers Binding89Artifacts exposes a Worker binding on `env.ARTIFACTS`.1011### Namespace Methods1213| Method | Use For |14|--------|---------|15| `create(name, opts?)` | Create a repo and receive its initial remote and token |16| `get(name)` | Resolve a repo handle for repo-scoped operations |17| `list(opts?)` | List repos in a namespace |18| `delete(name)` | Delete a repo |1920```typescript21const created = await env.ARTIFACTS.create("starter-repo", {22description: "Repository for automation experiments",23setDefaultBranch: "main"24});25const repo = await env.ARTIFACTS.get("starter-repo");26const page = await env.ARTIFACTS.list({ limit: 10 });27```2829Use the REST API when you need to import a repo from another HTTPS remote.3031### Repo Handle Methods3233Use a repo handle returned by `get()` or `create()`.3435| Method | Use For |36|--------|---------|37| `info()` | Read repo metadata, including the remote URL |38| `createToken(scope?, ttl?)` | Mint a repo-scoped read or write token |39| `listTokens()` | Inspect active tokens |40| `validateToken(token)` | Check whether a token is still valid |41| `revokeToken(tokenOrId)` | Revoke a token by ID or value |42| `fork(name, opts?)` | Fork one repo into another |4344```typescript45const repo = await env.ARTIFACTS.get("starter-repo");46if (!repo) throw new Error("Repo not found");4748const info = await repo.info();49const token = await repo.createToken("read", 3600);50const forked = await repo.fork("starter-repo-copy", {51defaultBranchOnly: true52});53```5455### Binding Notes5657- Current docs describe the runtime binding surface as `create`, `get`, `list`, `delete`, and repo-handle methods like `info`, `createToken`, and `fork`.58- Use `npx wrangler types` in the target project and treat the generated `worker-configuration.d.ts` as the source of truth for that environment.59- If generated types appear to expose `import()` or a different `get()` shape, verify the live docs before depending on those methods.6061Verify current runtime behavior in the live docs before depending on methods that are not shown in the Workers binding reference.6263## REST API6465Artifacts currently documents a namespace-scoped control plane:6667```txt68https://artifacts.cloudflare.net/v1/api/namespaces/$ARTIFACTS_NAMESPACE69```7071Some deployments also expose an `/edge/v1/api/...` base path. Verify the correct base URL for your environment in the live docs.7273Requests to the standard `/v1/api/...` routes use a **gateway JWT** with Bearer authentication.7475Returned repo tokens authenticate **Git operations** against the repo `remote`. They do not authenticate REST control-plane requests.7677Current docs show the standard Cloudflare v4 response envelope around REST results.7879### Repo Routes8081| Route | Use For |82|-------|---------|83| `POST /repos` | Create a repo |84| `GET /repos` | List repos |85| `GET /repos/:name` | Read repo metadata and remote |86| `DELETE /repos/:name` | Delete a repo |87| `POST /repos/:name/fork` | Fork a repo |88| `POST /repos/:name/import` | Import a public HTTPS remote |8990```bash91curl --request POST "$ARTIFACTS_BASE_URL/repos" \92--header "Authorization: Bearer $ARTIFACTS_JWT" \93--header "Content-Type: application/json" \94--data '{"name":"starter-repo"}'95```9697Important current details from the docs draft:98- `POST /repos/:name/import` accepts a full HTTPS remote URL such as GitHub or GitLab.99- Import supports options such as `branch`, `depth`, and `read_only`.100- Repo metadata includes fields such as description, default branch, timestamps, and the Git `remote`.101102### Token Routes103104| Route | Use For |105|-------|---------|106| `GET /repos/:name/tokens` | List repo tokens |107| `POST /tokens` | Create a token for a repo |108| `DELETE /tokens/:id` | Revoke a token by ID |109110Current docs show list-token filtering and pagination by token state. Retrieve the exact query shape from the live docs when you need token audit or cleanup workflows.111112Use **read** tokens for clone, fetch, pull, and indexing workflows. Use **write** tokens only when a workflow must push or otherwise mutate a repo.113114## Git-Compatible Access115116Artifacts returns repo `remote` URLs that work with standard git-over-HTTPS tooling.117118Recommended current auth pattern for local workflows:119120```bash121git -c http.extraHeader="Authorization: Bearer $ARTIFACTS_TOKEN" clone "$ARTIFACTS_REMOTE" artifacts-clone122```123124Use a self-contained Basic-auth remote only for short-lived commands that need credentials embedded in the URL.125126`read` tokens support `clone`, `fetch`, and `pull`. `git push` requires a `write` token.127128For large repos where startup time matters more than a full clone, Artifacts also documents **ArtifactFS**. Retrieve current details from `https://developers.cloudflare.com/artifacts/` when you need mount-style access.129