You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Throws if the repo does not exist or is not ready yet.
95
95
96
+
`get()` returns a handle to an existing repo. Use the handle to call async methods on the repo, such as `createToken()`, `listTokens()`, `revokeToken()`, and `fork()`.
`import()` returns repo metadata including `name`, `remote`, `defaultBranch`, and an initial token. Save the `remote` and `name` values if you need them later.
149
+
145
150
<TypeScriptExample>
146
151
147
152
```ts
@@ -166,8 +171,6 @@ async function importFromGitHub(artifacts: Artifacts) {
166
171
167
172
</TypeScriptExample>
168
173
169
-
Imported repos return the same create-style token format. The token encodes its expiry directly in the `?expires=` suffix.
@@ -185,18 +188,7 @@ async function deleteRepo(artifacts: Artifacts) {
185
188
186
189
## Repo handle methods
187
190
188
-
Call `await artifacts.get(name)` to get a repo handle. The handle extends `ArtifactsRepoInfo`, so repo metadata (`id`, `name`, `remote`, `defaultBranch`, etc.) is available directly as properties.
189
-
190
-
<TypeScriptExample>
191
-
192
-
```ts
193
-
asyncfunction getRemoteUrl(artifacts:Artifacts) {
194
-
const repo =awaitartifacts.get("starter-repo");
195
-
returnrepo.remote;
196
-
}
197
-
```
198
-
199
-
</TypeScriptExample>
191
+
Call `await artifacts.get(name)` to get a repo handle. Use the handle to call async methods on the repo.
Copy file name to clipboardExpand all lines: src/content/docs/artifacts/concepts/namespaces.mdx
+2-4Lines changed: 2 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,9 @@ products:
10
10
11
11
import { WranglerConfig } from"~/components";
12
12
13
-
Artifacts uses namespaces as top-level containers for repositories. Use them to separate repositories by environment, such as `prod`, `staging`, and `dev`, or by tenant and shard.
13
+
Artifacts uses namespaces as top-level containers for repositories. Use them to separate repositories by environment, such as `prod`, `staging`, and `dev`, by tenant, or shard.
14
14
15
-
You do not create namespaces separately.
16
-
17
-
Choose a namespace name, then use that name in your Wrangler config or REST API path when you create the first repo. Artifacts creates the namespace implicitly at that point.
15
+
Namespaces are created implicitly — there is no separate step to create one. You choose a namespace name, then reference it in your Wrangler config or REST API path. The first time you create a repository under that name, Artifacts creates the namespace for you automatically.
Copy file name to clipboardExpand all lines: src/content/docs/artifacts/examples/git-client.mdx
+14-2Lines changed: 14 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,40 +8,52 @@ products:
8
8
- artifacts
9
9
---
10
10
11
-
Use this pattern when you want to discover a repo over the REST API and then hand the returned HTTPS remote to a standard Git client.
11
+
You can use a standard Git client to interact with Artifacts repos. This example walks through clone, but the same approach works for fetch, pull, push, and any other Git operation.
12
+
13
+
To do this, you need to:
14
+
- Fetch the repo's remote URL from the REST API
15
+
- Mint a short-lived token scoped to that repo
16
+
17
+
Once you have the remote URL and token, you can use them to run Git commands against the repo.
12
18
13
19
This example assumes the repo already exists and that you have a [Cloudflare API token](/fundamentals/api/get-started/create-token/) with **Artifacts** > **Edit**.
14
20
15
21
## Fetch the remote and clone the repo
16
22
17
-
First, fetch the repo metadata from the REST API. Then mint a read token for that repo and use the returned remote with `git clone`.
23
+
Replace the placeholder values with your account ID, API token, and repo name. The script fetches the repo's remote URL from the API, mints a read-only token that expires in one hour, and clones the repo to a local directory.
18
24
19
25
The example below uses `jq` to extract fields from the JSON responses.
Use [isomorphic-git](https://isomorphic-git.org/)in a Cloudflare Worker when you need Git operations without a Git binary.
13
+
Use [isomorphic-git](https://isomorphic-git.org/)to run Git operations on Artifacts repos directly from a Cloudflare Worker.
14
14
15
-
This works with Artifacts because Artifacts exposes standard Git smart HTTP remotes. In Workers, pair `isomorphic-git/http/web` with a small in-memory filesystem because the runtime does not expose a local disk.
15
+
The Artifacts binding creates and manages repos, but it cannot read or write files inside them — for that, you need Git. Since Workers do not have a git binary or a local filesystem, `isomorphic-git` fills that gap. It provides Git operations like init, commit, and push as JavaScript function calls, using an in-memory filesystem in place of a real disk.
16
16
17
-
## Install the dependency
17
+
Use this when your Worker needs to programmatically build and push file trees to an Artifacts repo — for example, an AI agent that generates code and commits it, or an automation that clones a repo, modifies files, and pushes changes back.
18
+
19
+
## Prerequisites
20
+
21
+
Follow the [Artifacts Workers setup guide](/artifacts/get-started/workers/) to set up a Worker with an Artifacts binding.
Copy file name to clipboardExpand all lines: src/content/docs/artifacts/get-started/rest-api.mdx
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,11 +29,11 @@ You need:
29
29
- A local `git` client.
30
30
-`jq`, if you want to extract response fields automatically.
31
31
32
-
For Workers-based access instead of direct HTTP calls, use the [Workers get started guide](/artifacts/get-started/workers/).
32
+
If you want to create and manage repos directly from a Worker (instead of calling the REST API), use the [Workers get started guide](/artifacts/get-started/workers/).
33
33
34
34
## 1. Export your environment variables
35
35
36
-
Set the variables used in the examples:
36
+
Set the following variables using your Cloudflare account ID and Artifacts API token:
Use a unique repo name each time you run this guide.
47
47
48
-
Artifacts uses Bearer authentication for control-plane requests:
48
+
Artifacts uses Bearer authentication for API requests:
49
49
50
50
```txt
51
51
Authorization: Bearer $CLOUDFLARE_API_TOKEN
@@ -82,10 +82,11 @@ The response resembles the following:
82
82
"messages": []
83
83
}
84
84
```
85
+
The response includes two values which you will need for Git operations:
86
+
-`remote`: the Git remote URL for this repo. `<ACCOUNT_ID>` will be your actual Cloudflare account ID. Use this URL for all Git commands (git push, git clone). Note that this uses a different URL than the REST API you used to create the repo.
87
+
-`token`: a short-lived credential for Git operations. The token encodes its expiry directly in the `?expires=` suffix as a Unix timestamp.
85
88
86
-
The REST control-plane base URL and the returned Git remote use different hosts. Use the exact `result.remote` value for Git operations. The example above uses `<ACCOUNT_ID>` as a placeholder for your Cloudflare account ID.
87
89
88
-
The returned token encodes its expiry directly in the `?expires=` suffix.
89
90
90
91
Copy the `remote` and `token` values from `result` into local shell variables:
0 commit comments