From e6e75ef05c09318ae06090ddbac7b8e0fb5114dc Mon Sep 17 00:00:00 2001 From: Jo Franchetti Date: Wed, 8 May 2024 09:43:34 +0100 Subject: [PATCH] move files --- subhosting/api/authentication.md | 44 ++++++++++ .../api/images/subhosting-org-structure.svg | 87 +++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 subhosting/api/authentication.md create mode 100644 subhosting/api/images/subhosting-org-structure.svg diff --git a/subhosting/api/authentication.md b/subhosting/api/authentication.md new file mode 100644 index 000000000..9e4a32e61 --- /dev/null +++ b/subhosting/api/authentication.md @@ -0,0 +1,44 @@ +# Authentication + +Developers can provision projects, domains, KV databases, and other resources +using the Subhosting REST API. + +## Endpoint and authentication + +The base URL for the Subhosting REST API v1 is below. + +```console +https://api.deno.com/v1/ +``` + +The v1 API uses +[HTTP bearer token](https://swagger.io/docs/specification/authentication/bearer-authentication/) +authentication. You can create an access token to use the API in the dashboard +[here](https://dash.deno.com/account#access-tokens). Most API requests will also +require your organization ID. You can retrieve yours from the Deno Deploy +dashboard for your organization. + +![Find your org ID here](./images/org-id.png) + +Using both your organization ID and your access token, you can test your API +access by listing all the projects associated with your organization. Here is an +example Deno script you can use to access the API. + +```typescript +// Replace these with your own! +const organizationId = "a75a9caa-b8ac-47b3-a423-3f2077c58731"; +const token = "ddo_u7mo08lBNHm8GMGLhtrEVfcgBsCuSp36dumX"; + +const res = await fetch( + `https://api.deno.com/v1/organizations/${organizationId}/projects`, + { + method: "GET", + headers: { + Authorization: `Bearer ${token}`, + }, + }, +); + +const response = await res.json(); +console.log(response); +``` diff --git a/subhosting/api/images/subhosting-org-structure.svg b/subhosting/api/images/subhosting-org-structure.svg new file mode 100644 index 000000000..6fb054e0b --- /dev/null +++ b/subhosting/api/images/subhosting-org-structure.svg @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +