Skip to content

Commit af22809

Browse files
committed
[Artifacts] tighten docs examples
1 parent 5605a1c commit af22809

12 files changed

Lines changed: 179 additions & 209 deletions

File tree

src/content/docs/artifacts/api/git-protocol.mdx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sidebar:
88

99
Artifacts exposes Git access for every Artifacts repository.
1010

11-
Each repo has a standard Git smart HTTP remote at `https://{accountId}.artifacts.cloudflare.dev/git/{namespace}/{repo}.git`.
11+
Each repo has a standard Git smart HTTP remote at `https://{accountId}.artifacts.cloudflare.net/git/{namespace}/{repo}.git`.
1212

1313
Use the returned repo `remote` with a regular Git client for `clone`, `fetch`, `pull`, and `push`.
1414

@@ -18,17 +18,29 @@ Git routes accept repo access tokens in two forms:
1818

1919
| Format | Details | Example |
2020
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
21-
| HTTP Basic auth in the remote URL | Recommended for simple `git clone` and `git push` commands. Put the token secret in the password slot. | `https://x:<token-secret>@<accountId>.artifacts.cloudflare.dev/git/<namespace>/<repo>.git` |
22-
| Bearer token in `http.extraHeader` | Use the full token string returned by the control plane. This works well when you do not want credentials embedded in the remote URL. | `git -c http.extraHeader="Authorization: Bearer $ARTIFACTS_TOKEN" clone "$ARTIFACTS_REMOTE" artifacts-clone` |
21+
| Bearer token in `http.extraHeader` | Recommended for local workflows. Use the full token string returned by the control plane and keep credentials out of the remote URL. | `git -c http.extraHeader="Authorization: Bearer $ARTIFACTS_TOKEN" clone "$ARTIFACTS_REMOTE" artifacts-clone` |
22+
| HTTP Basic auth in the remote URL | Use for short-lived, one-off commands when you need a self-contained remote. Put the token secret in the password slot. | `https://x:<token-secret>@<accountId>.artifacts.cloudflare.net/git/<namespace>/<repo>.git` |
2323

2424
### Token format
2525

2626
Repo tokens are issued in the control-plane response format `art_v1_<40 hex>?expires=<unix_seconds>`.
2727

28-
### HTTPS remote (recommended)
28+
### Git `extraHeader` parameter
29+
30+
Git's [`http.extraHeader`](https://git-scm.com/docs/git-config#Documentation/git-config.txt-httpextraHeader) setting lets you attach an HTTP header to git requests.
31+
32+
If you want to use the full token string returned by the API, pass it as a Bearer token:
33+
34+
```sh
35+
git -c http.extraHeader="Authorization: Bearer $ARTIFACTS_TOKEN" clone "$ARTIFACTS_REMOTE" artifacts-clone
36+
```
37+
38+
### HTTPS remote with Basic auth
2939

3040
For the URL form, use the token secret in the password slot. Artifacts ignores the Basic auth username.
3141

42+
Use this form only when you need a self-contained remote URL for a short-lived command.
43+
3244
```sh
3345
export ARTIFACTS_TOKEN_SECRET="${ARTIFACTS_TOKEN%%\?expires=*}"
3446
export ARTIFACTS_AUTH_REMOTE="https://x:${ARTIFACTS_TOKEN_SECRET}@${ARTIFACTS_REMOTE#https://}"
@@ -39,22 +51,11 @@ git clone "$ARTIFACTS_AUTH_REMOTE" artifacts-clone
3951
```
4052

4153
```sh
42-
git remote add origin "$ARTIFACTS_AUTH_REMOTE"
43-
git push -u origin main
54+
git push "$ARTIFACTS_AUTH_REMOTE" HEAD:main
4455
```
4556

4657
Use any non-empty username in the URL. Artifacts accepts that username but does not otherwise use or log it, so `x` is just a placeholder.
4758

48-
### Git `extraHeader` parameter
49-
50-
Git's [`http.extraHeader`](https://git-scm.com/docs/git-config#Documentation/git-config.txt-httpextraHeader) setting lets you attach an HTTP header to git requests.
51-
52-
If you want to use the full token string returned by the API, pass it as a Bearer token:
53-
54-
```sh
55-
git -c http.extraHeader="Authorization: Bearer $ARTIFACTS_TOKEN" clone "$ARTIFACTS_REMOTE" artifacts-clone
56-
```
57-
5859
## Protocol support
5960

6061
Artifacts supports Git protocol v1 and v2 for clone and fetch. Git clients negotiate the protocol automatically.

src/content/docs/artifacts/api/rest-api.mdx

Lines changed: 66 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ head:
99
content: REST API · Artifacts
1010
---
1111

12-
import { LinkCard, MetaInfo, Type } from "~/components";
12+
import { LinkCard, MetaInfo, Type, TypeScriptExample } from "~/components";
1313

1414
Use the Artifacts REST API to manage repos, remotes, forks, imports, and tokens from external systems.
1515

@@ -18,13 +18,13 @@ Use the Artifacts REST API to manage repos, remotes, forks, imports, and tokens
1818
Artifacts REST routes use this base path:
1919

2020
```txt
21-
https://artifacts.cloudflare.dev/v1/api/namespaces/{namespace}
21+
https://artifacts.cloudflare.net/v1/api/namespaces/{namespace}
2222
```
2323

2424
Some edge deployments also expose this base path:
2525

2626
```txt
27-
https://artifacts.cloudflare.dev/edge/v1/api/namespaces/{namespace}
27+
https://artifacts.cloudflare.net/edge/v1/api/namespaces/{namespace}
2828
```
2929

3030
Requests to `/v1/api/...` use Bearer authentication:
@@ -41,13 +41,17 @@ The following examples assume:
4141
export ARTIFACTS_NAMESPACE="default"
4242
export ARTIFACTS_REPO="starter-repo"
4343
export ARTIFACTS_JWT="<YOUR_GATEWAY_JWT>"
44-
export ARTIFACTS_BASE_URL="https://artifacts.cloudflare.dev/v1/api/namespaces/$ARTIFACTS_NAMESPACE"
44+
export ARTIFACTS_BASE_URL="https://artifacts.cloudflare.net/v1/api/namespaces/$ARTIFACTS_NAMESPACE"
4545
```
4646

4747
All responses use the standard Cloudflare v4 envelope.
4848

49+
Returned repo tokens are secrets. Do not log them or store them in long-lived remotes unless your workflow requires it.
50+
4951
## Shared types
5052

53+
<TypeScriptExample typescriptFirst={true}>
54+
5155
```ts
5256
export type NamespaceName = string;
5357
export type RepoName = string;
@@ -121,6 +125,8 @@ export interface TokenInfo {
121125
}
122126
```
123127

128+
</TypeScriptExample>
129+
124130
## Repos
125131

126132
### Create a repo
@@ -136,6 +142,8 @@ Request body:
136142

137143
Response type:
138144

145+
<TypeScriptExample omitTabs={true}>
146+
139147
```ts
140148
export interface CreateRepoRequest {
141149
name: RepoName;
@@ -157,6 +165,8 @@ export interface CreateRepoResult {
157165
export type CreateRepoResponse = ApiEnvelope<CreateRepoResult>;
158166
```
159167

168+
</TypeScriptExample>
169+
160170
```bash
161171
curl --request POST "$ARTIFACTS_BASE_URL/repos" \
162172
--header "Authorization: Bearer $ARTIFACTS_JWT" \
@@ -176,9 +186,9 @@ curl --request POST "$ARTIFACTS_BASE_URL/repos" \
176186
"name": "starter-repo",
177187
"description": "Repository for automation experiments",
178188
"default_branch": "main",
179-
"remote": "https://<ACCOUNT>.artifacts.cloudflare.dev/git/default/starter-repo.git",
189+
"remote": "https://<ACCOUNT_ID>.artifacts.cloudflare.net/git/default/starter-repo.git",
180190
"token": "art_v1_0123456789abcdef0123456789abcdef01234567?expires=1760000000",
181-
"expires_at": "2026-04-08T12:00:00.000Z"
191+
"expires_at": "<ISO_TIMESTAMP>"
182192
},
183193
"success": true,
184194
"errors": [],
@@ -200,6 +210,8 @@ Query parameters:
200210

201211
Response type:
202212

213+
<TypeScriptExample typescriptFirst={true}>
214+
203215
```ts
204216
export interface ListReposQuery {
205217
limit?: number;
@@ -212,6 +224,8 @@ export interface ListReposQuery {
212224
export type ListReposResponse = ApiEnvelope<RepoInfo[]>;
213225
```
214226

227+
</TypeScriptExample>
228+
215229
```bash
216230
curl "$ARTIFACTS_BASE_URL/repos?limit=20&sort=updated_at&direction=desc" \
217231
--header "Authorization: Bearer $ARTIFACTS_JWT"
@@ -225,9 +239,9 @@ curl "$ARTIFACTS_BASE_URL/repos?limit=20&sort=updated_at&direction=desc" \
225239
"name": "starter-repo",
226240
"description": "Repository for automation experiments",
227241
"default_branch": "main",
228-
"created_at": "2026-04-07T12:00:00.000Z",
229-
"updated_at": "2026-04-07T12:30:00.000Z",
230-
"last_push_at": "2026-04-07T12:30:00.000Z",
242+
"created_at": "<ISO_TIMESTAMP>",
243+
"updated_at": "<ISO_TIMESTAMP>",
244+
"last_push_at": "<ISO_TIMESTAMP>",
231245
"source": null,
232246
"read_only": false
233247
}
@@ -249,10 +263,14 @@ Route: `GET /repos/:name`
249263

250264
Response type:
251265

266+
<TypeScriptExample omitTabs={true}>
267+
252268
```ts
253269
export type GetRepoResponse = ApiEnvelope<RemoteRepoInfo>;
254270
```
255271

272+
</TypeScriptExample>
273+
256274
```bash
257275
curl "$ARTIFACTS_BASE_URL/repos/$ARTIFACTS_REPO" \
258276
--header "Authorization: Bearer $ARTIFACTS_JWT"
@@ -265,12 +283,12 @@ curl "$ARTIFACTS_BASE_URL/repos/$ARTIFACTS_REPO" \
265283
"name": "starter-repo",
266284
"description": "Repository for automation experiments",
267285
"default_branch": "main",
268-
"created_at": "2026-04-07T12:00:00.000Z",
269-
"updated_at": "2026-04-07T12:30:00.000Z",
270-
"last_push_at": "2026-04-07T12:30:00.000Z",
286+
"created_at": "<ISO_TIMESTAMP>",
287+
"updated_at": "<ISO_TIMESTAMP>",
288+
"last_push_at": "<ISO_TIMESTAMP>",
271289
"source": null,
272290
"read_only": false,
273-
"remote": "https://<ACCOUNT>.artifacts.cloudflare.dev/git/default/starter-repo.git"
291+
"remote": "https://<ACCOUNT_ID>.artifacts.cloudflare.net/git/default/starter-repo.git"
274292
},
275293
"success": true,
276294
"errors": [],
@@ -286,6 +304,8 @@ This route returns `202 Accepted`.
286304

287305
Response type:
288306

307+
<TypeScriptExample omitTabs={true}>
308+
289309
```ts
290310
export interface DeleteRepoResult {
291311
id: string;
@@ -294,6 +314,8 @@ export interface DeleteRepoResult {
294314
export type DeleteRepoResponse = ApiEnvelope<DeleteRepoResult>;
295315
```
296316

317+
</TypeScriptExample>
318+
297319
```bash
298320
curl --request DELETE "$ARTIFACTS_BASE_URL/repos/$ARTIFACTS_REPO" \
299321
--header "Authorization: Bearer $ARTIFACTS_JWT"
@@ -323,6 +345,8 @@ Request body:
323345

324346
Response type:
325347

348+
<TypeScriptExample omitTabs={true}>
349+
326350
```ts
327351
export interface ForkRepoRequest {
328352
name: RepoName;
@@ -338,6 +362,8 @@ export interface ForkRepoResult extends CreateRepoResult {
338362
export type ForkRepoResponse = ApiEnvelope<ForkRepoResult>;
339363
```
340364

365+
</TypeScriptExample>
366+
341367
```bash
342368
curl --request POST "$ARTIFACTS_BASE_URL/repos/$ARTIFACTS_REPO/fork" \
343369
--header "Authorization: Bearer $ARTIFACTS_JWT" \
@@ -357,9 +383,9 @@ curl --request POST "$ARTIFACTS_BASE_URL/repos/$ARTIFACTS_REPO/fork" \
357383
"name": "starter-repo-copy",
358384
"description": "Repository for automation experiments",
359385
"default_branch": "main",
360-
"remote": "https://<ACCOUNT>.artifacts.cloudflare.dev/git/default/starter-repo-copy.git",
386+
"remote": "https://<ACCOUNT_ID>.artifacts.cloudflare.net/git/default/starter-repo-copy.git",
361387
"token": "art_v1_89abcdef0123456789abcdef0123456789abcdef?expires=1760003600",
362-
"expires_at": "2026-04-08T13:00:00.000Z",
388+
"expires_at": "<ISO_TIMESTAMP>",
363389
"objects": 128
364390
},
365391
"success": true,
@@ -381,6 +407,8 @@ Request body:
381407

382408
Response type:
383409

410+
<TypeScriptExample omitTabs={true}>
411+
384412
```ts
385413
export interface ImportRepoRequest {
386414
url: string;
@@ -392,6 +420,8 @@ export interface ImportRepoRequest {
392420
export type ImportRepoResponse = ApiEnvelope<CreateRepoResult>;
393421
```
394422

423+
</TypeScriptExample>
424+
395425
Pass a full HTTPS Git remote URL, for example `https://github.com/facebook/react` or `https://gitlab.com/group/project.git`.
396426

397427
```bash
@@ -412,9 +442,9 @@ curl --request POST "$ARTIFACTS_BASE_URL/repos/react-mirror/import" \
412442
"name": "react-mirror",
413443
"description": null,
414444
"default_branch": "main",
415-
"remote": "https://<ACCOUNT>.artifacts.cloudflare.dev/git/default/react-mirror.git",
445+
"remote": "https://<ACCOUNT_ID>.artifacts.cloudflare.net/git/default/react-mirror.git",
416446
"token": "art_v1_fedcba9876543210fedcba9876543210fedcba98?expires=1760007200",
417-
"expires_at": "2026-04-08T14:00:00.000Z"
447+
"expires_at": "<ISO_TIMESTAMP>"
418448
},
419449
"success": true,
420450
"errors": [],
@@ -436,6 +466,8 @@ Query parameters:
436466

437467
Response type:
438468

469+
<TypeScriptExample omitTabs={true}>
470+
439471
```ts
440472
export interface ListTokensQuery {
441473
state?: TokenState | "all";
@@ -446,6 +478,8 @@ export interface ListTokensQuery {
446478
export type ListTokensResponse = ApiEnvelope<TokenInfo[]>;
447479
```
448480

481+
</TypeScriptExample>
482+
449483
```bash
450484
curl "$ARTIFACTS_BASE_URL/repos/$ARTIFACTS_REPO/tokens?state=all&per_page=30&page=1" \
451485
--header "Authorization: Bearer $ARTIFACTS_JWT"
@@ -458,8 +492,8 @@ curl "$ARTIFACTS_BASE_URL/repos/$ARTIFACTS_REPO/tokens?state=all&per_page=30&pag
458492
"id": "tok_123",
459493
"scope": "read",
460494
"state": "active",
461-
"created_at": "2026-04-07T12:00:00.000Z",
462-
"expires_at": "2026-04-07T13:00:00.000Z"
495+
"created_at": "<ISO_TIMESTAMP>",
496+
"expires_at": "<ISO_TIMESTAMP>"
463497
}
464498
],
465499
"success": true,
@@ -487,6 +521,8 @@ Request body:
487521

488522
Response type:
489523

524+
<TypeScriptExample omitTabs={true}>
525+
490526
```ts
491527
export interface CreateTokenRequest {
492528
repo: RepoName;
@@ -504,6 +540,8 @@ export interface CreateTokenResult {
504540
export type CreateTokenResponse = ApiEnvelope<CreateTokenResult>;
505541
```
506542

543+
</TypeScriptExample>
544+
507545
```bash
508546
curl --request POST "$ARTIFACTS_BASE_URL/tokens" \
509547
--header "Authorization: Bearer $ARTIFACTS_JWT" \
@@ -521,7 +559,7 @@ curl --request POST "$ARTIFACTS_BASE_URL/tokens" \
521559
"id": "tok_123",
522560
"plaintext": "art_v1_0123456789abcdef0123456789abcdef01234567?expires=1760000000",
523561
"scope": "read",
524-
"expires_at": "2026-04-07T13:00:00.000Z"
562+
"expires_at": "<ISO_TIMESTAMP>"
525563
},
526564
"success": true,
527565
"errors": [],
@@ -535,6 +573,8 @@ Route: `DELETE /tokens/:id`
535573

536574
Response type:
537575

576+
<TypeScriptExample omitTabs={true}>
577+
538578
```ts
539579
export interface RevokeTokenResult {
540580
id: string;
@@ -543,6 +583,8 @@ export interface RevokeTokenResult {
543583
export type RevokeTokenResponse = ApiEnvelope<RevokeTokenResult>;
544584
```
545585

586+
</TypeScriptExample>
587+
546588
```bash
547589
curl --request DELETE "$ARTIFACTS_BASE_URL/tokens/tok_123" \
548590
--header "Authorization: Bearer $ARTIFACTS_JWT"
@@ -563,6 +605,8 @@ curl --request DELETE "$ARTIFACTS_BASE_URL/tokens/tok_123" \
563605

564606
Application errors also use the v4 envelope:
565607

608+
<TypeScriptExample omitTabs={true}>
609+
566610
```ts
567611
export interface ApiError {
568612
code: number;
@@ -574,6 +618,8 @@ export interface ApiError {
574618
}
575619
```
576620

621+
</TypeScriptExample>
622+
577623
## Next steps
578624

579625
<LinkCard

0 commit comments

Comments
 (0)