Files
coder/docs/reference/api/enterprise.md
T
Bobby Ho 20a41c067e feat: reject secret creation and fix reporting for public clients (#28097)
**TL;DR**

On top of #28047, closing the last two gaps in the stack split out of
#27873. A public client can now register (#28046) and exchange a code
(#28047), but the admin secrets API will still issue it a secret that
authenticates nothing, and the registration responses still report an
auth method the token endpoint will not accept.

| PR | What it does |
|---|---|
| #27712 | Schema: `app_secret_id` becomes nullable and tokens gain an
always-populated `app_id`, so ownership checks work without a secret
row. |
| #28041 | Accepts bare custom-scheme redirect URIs (`vscode://`,
`cursor://`) that native apps actually register. |
| #28043 | Derives and stores `client_type` (public vs confidential)
from the requested `token_endpoint_auth_method`, and pins it across
updates. |
| #28046 | Registration issues no secret for a public client and returns
no `client_secret`. |
| #28047 | The token endpoint accepts the exchange without a
`client_secret`. Discovery advertises `none`. |
| **#28097 (this)** | The admin secrets API refuses to create a secret
for a public client, and registration, read, and update report the auth
method the token endpoint actually enforces. |

A public client can only come into existence through dynamic client
registration, which is off by default, so neither guard is reachable
until DCR is enabled.

**Where in the flow**

- `POST /oauth2-provider/apps/{app}/secrets`, the admin secrets API. The
rest of the secret lifecycle is untouched: `GET` and `DELETE` are
unchanged, and a confidential app behaves exactly as before.
- The three RFC 7591 and 7592 responses that carry
`token_endpoint_auth_method`: registration (`POST`), read (`GET`), and
update (`PUT`). Only what is reported changes; the stored column is left
as the client sent it.
- Authorize, token exchange, refresh, and revocation are untouched.

**What it satisfies**

- RFC 7591 §2: `none` means the client is public and "does not have a
client secret", so the secrets API should not create one for it.
- RFC 7591 §3.2.1: the server MUST return all registered metadata and
MAY replace a requested value with a suitable one. Reporting the
enforced method in place of a stored one that contradicts `client_type`
is that substitution.
- RFC 7592 §2.2: an update MUST include all metadata as returned by a
previous registration, read, or update. Because clients echo back what
Coder reports, reporting the enforced method is what lets a legacy row
heal on the client's next `PUT`.
- RFC 7591 §2 default: an app with no stored method reports
`client_secret_basic`, which is both the RFC default and what
`ApplyDefaults` substitutes on update.
- OAuth 2.1 §3.2.1: the token endpoint enforces on `client_type`, so a
reported method that disagrees with it tells a client to authenticate in
a way the server will reject.

---

- `CreateAppSecret` returns 400 for a public client before generating
anything. The secret would authenticate nothing, since the token
endpoint no longer checks one for a public client. Deleting it would be
worse: `oauth2_provider_app_tokens.app_secret_id` is `ON DELETE
CASCADE`, so removing a confidential app's secret takes its tokens with
it, but a public client's tokens carry a NULL `app_secret_id` (#27712)
and survive. An admin who deleted the secret would think they had cut
off the client when they had not.
- `reportedAuthMethod()` replaces the raw stored value in all three
registration responses. It returns the stored method when it agrees with
`client_type`, `none` for a public app, and `client_secret_basic`
otherwise.
- The rows that can disagree are clients registered before #28043
derived the type from the method: the method was stored as sent while
the type was always `confidential`. Such a client holds a secret its
exchange still requires, while `GET` reported `none` and told it to drop
that secret.
- The stored column is deliberately not rewritten, so the response can
still differ from the row. That divergence is what a read-modify-write
client resolves on its next update, and the test asserts the row keeps
what the client sent.
- Coverage: the secrets guard asserts the 400 and that no partial secret
row was left behind. A table test walks `GET` then `PUT` over six
stored-method and client-type pairs: the legacy mismatch in both resend
shapes, the reverse mismatch that registration cannot produce but the
function still handles, an empty stored method, and the single pair that
already agrees and must be reported as stored.
- Docs: the client type is fixed at registration and a type-changing
update is rejected with `invalid_client_metadata` (behavior from #28043
that was never written down), plus what a legacy `none` client now sees.

Refs
https://linear.app/codercom/issue/ENG-3029/oauth2-support-public-client



## Manual Tests

Verified by hand against a local dev deployment
(`v2.36.3-devel+c85e4621ef`, dev Postgres), in addition to the automated
suite.

Both guards are reachable only through dynamic client registration,
which was confirmed off by default on this deployment and enabled for
the run. Two of the scenarios need a row where `client_type` and
`token_endpoint_auth_method` disagree, which registration cannot produce
since #28043 derives one from the other, so those rows were seeded by
updating the method column directly on a purpose-built client.

| # | Scenario | Result |
|---|----------|--------|
| 1 | Secrets API refuses a public client, with the guard's own message
| Pass |
| 2 | No partial secret row is left behind by the rejection | Pass |
| 3 | A confidential app's secret create, list, and delete are unchanged
| Pass |
| 4 | Admin-created apps are always confidential, so the guard is
unreachable there | Pass |
| 5 | When stored method and client type agree, the stored value is
reported unchanged | Pass |
| 6 | A legacy confidential row storing `none` reports
`client_secret_basic` | Pass |
| 7 | The reported method is the one the token endpoint enforces, in
both directions | Pass |
| 8 | An update resending the stored value is accepted and leaves the
row alone | Pass |
| 9 | An update resending the reported value heals the row | Pass |
| 10 | The reverse mismatch, a public row storing a secret method,
reports `none` | Pass |
| 11 | An empty or unrecognized stored method falls back to
`client_secret_basic` | Pass |
| 12 | Type-changing updates are rejected both ways,
`client_secret_basic` to `client_secret_post` is allowed | Pass |
| 13 | Regression sweep of the merged stack, discovery through
revocation | Pass |
| 14 | Every claim in the new docs paragraphs matches observed behavior
| Pass |

No correctness defects found. Commands and captured output for each
scenario below.

**Two notes for anyone re-running this.**

The previous runbook for this stack asserts the opposite of scenario 12:
it flips a confidential client to public with a `PUT` and records `200`.
That was correct before #28043 pinned the client type. The `400` here is
the fix, not a regression.

Generate the PKCE verifier with enough entropy that stripping `=+/`
still leaves 43 characters. The `openssl rand -base64 32 | tr -d "=+/" |
cut -c -43` recipe yields 38 to 43, so most runs are rejected by the
token endpoint under RFC 7636 section 4.1 with an error that looks
unrelated. Same trap noted in #28045.

<details>
<summary>Shell helpers used throughout</summary>

```bash
export BASE_URL=http://localhost:3000
export AUTH_HEADER="Coder-Session-Token: $(cat ./.coderv2/session)"
export PGURL="postgres://coder@localhost:$(cat ./.coderv2/postgres/port)/coder?sslmode=disable&password=$(cat ./.coderv2/postgres/password)"

# Enable DCR; both guards are unreachable without it.
curl -s -X PUT "$BASE_URL/api/v2/oauth2-provider/settings" -H "$AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{"dynamic_client_registration_enabled": true}'

# Print "HTTP <code>" then the body.
show() {
  local out; out=$(curl -s -w '\n%{http_code}' "$@")
  echo "HTTP $(printf '%s\n' "$out" | tail -n1)"
  printf '%s\n' "$out" | sed '$d' | jq . 2>/dev/null || printf '%s\n' "$out" | sed '$d'
}

# $1=name, $2=auth method ("" to omit the field).
register() {
  local body
  if [ -z "$2" ]; then
    body=$(jq -nc --arg n "$1" '{client_name:$n,redirect_uris:["http://localhost:9876/callback"]}')
  else
    body=$(jq -nc --arg n "$1" --arg m "$2" '{client_name:$n,redirect_uris:["http://localhost:9876/callback"],token_endpoint_auth_method:$m}')
  fi
  curl -s -X POST "$BASE_URL/oauth2/register" -H "Content-Type: application/json" -d "$body"
}

# The stored row, as opposed to what the API reports.
stored() {
  psql "$PGURL" -At -c "select client_type || ' | ' || coalesce(token_endpoint_auth_method,'<NULL>')
    from oauth2_provider_apps where id = '$1';"
}

# 43 characters from the unreserved set, always. See the note above.
gen_verifier() { openssl rand -base64 96 | tr -d "=+/\n" | cut -c -43; }
challenge_for() { printf '%s' "$1" | openssl dgst -sha256 -binary | base64 | tr -d "=" | tr '+/' '-_'; }

# Full PKCE authorize plus exchange. $1=client_id, $2=client_secret ("" for none).
exchange() {
  local verifier challenge redirect code args
  verifier=$(gen_verifier); challenge=$(challenge_for "$verifier")
  redirect=$(curl -s -X POST \
    "$BASE_URL/oauth2/authorize?client_id=$1&response_type=code&redirect_uri=http://localhost:9876/callback&state=$(openssl rand -hex 16)&code_challenge=$challenge&code_challenge_method=S256" \
    -H "$AUTH_HEADER" -w '\n%{redirect_url}' -o /dev/null)
  code=$(printf '%s' "$redirect" | grep -oE 'code=[^&]+' | sed 's/code=//')
  args=(-d "grant_type=authorization_code" -d "code=$code" -d "client_id=$1"
        -d "redirect_uri=http://localhost:9876/callback" -d "code_verifier=$verifier")
  [ -n "$2" ] && args+=(-d "client_secret=$2")
  curl -s -X POST "$BASE_URL/oauth2/tokens" -H "Content-Type: application/x-www-form-urlencoded" "${args[@]}"
}
```

</details>

<details>
<summary>1. Secrets API refuses a public client</summary>

A bare non-`201` would also be produced by a request that failed on
authentication, routing, or a malformed UUID before reaching the guard,
so the status and the message are both asserted.

```bash
PUB=$(register manual-28097-public none)
PUB_ID=$(echo "$PUB" | jq -r '.client_id')
stored "$PUB_ID"
show -X POST "$BASE_URL/api/v2/oauth2-provider/apps/$PUB_ID/secrets" -H "$AUTH_HEADER"
```

```text
public | none
HTTP 400
{
  "message": "Cannot create a client secret for a public OAuth2 app.",
  "detail": "Public clients authenticate with PKCE and have no client secret. The client type is fixed at registration, so register a new confidential client instead."
}
```

The message is the guard's own, so execution reached `CreateAppSecret`
and returned at the `IsPublic()` check. The detail points at registering
a new confidential client, which scenario 12 confirms is the only
remedy.

</details>

<details>
<summary>2. No partial secret row is left behind</summary>

The guard returns before `GenerateSecret()`, so nothing should exist at
either layer. The count was already `0` at registration, and a
confidential app is queried the same way as a control, so `0` is not
merely what this query always returns.

```bash
curl -s "$BASE_URL/api/v2/oauth2-provider/apps/$PUB_ID/secrets" -H "$AUTH_HEADER" | jq -c .
psql "$PGURL" -At -c "select count(*) from oauth2_provider_app_secrets where app_id = '$PUB_ID';"
psql "$PGURL" -At -c "select count(*) from oauth2_provider_app_secrets where app_id = '$CONF_ID';"
```

```text
[]
0
1
```

</details>

<details>
<summary>3. A confidential app's secret lifecycle is unchanged</summary>

```bash
CONF=$(register manual-28097-confidential "")
CONF_ID=$(echo "$CONF" | jq -r '.client_id')
show -X POST "$BASE_URL/api/v2/oauth2-provider/apps/$CONF_ID/secrets" -H "$AUTH_HEADER"
curl -s "$BASE_URL/api/v2/oauth2-provider/apps/$CONF_ID/secrets" -H "$AUTH_HEADER" | jq -c '[.[].id]'
curl -s -X DELETE "$BASE_URL/api/v2/oauth2-provider/apps/$CONF_ID/secrets/$SECRET_ID" \
  -H "$AUTH_HEADER" -o /dev/null -w "delete: HTTP %{http_code}\n"
```

```text
HTTP 201
{
  "id": "da7a1029-47c4-435e-988a-557ffa4aeacf",
  "client_secret_full": "coder_POUtoElODM_<redacted>"
}
["b2fc55b6-...","da7a1029-...","24f8f8c2-..."]
delete: HTTP 204
["b2fc55b6-...","da7a1029-..."]
```

Create, list, and delete all behave as before. The guard keys on
`client_type` and nothing else on this path changed.

Unrelated observation, not a finding against this PR: the listing
returns two different `client_secret_truncated` formats. Secrets issued
at registration are asterisk-padded (`***...TzqEOt`, from
`createDisplaySecret`), while secrets issued through the admin API show
the bare last six characters (`Rixs60`). Both write the same column and
surface through the same field. Cosmetic and pre-existing, but a UI
listing both kinds together would render them inconsistently.

</details>

<details>
<summary>4. Admin-created apps are always confidential</summary>

`postOAuth2ProviderApp` hardcodes the client type, so the guard is
unreachable through the admin create path.

```bash
ADMIN_APP=$(curl -s -X POST "$BASE_URL/api/v2/oauth2-provider/apps" -H "$AUTH_HEADER" \
  -H "Content-Type: application/json" \
  -d '{"name":"manual-28097-admin","callback_url":"http://localhost:9876/callback"}')
ADMIN_ID=$(echo "$ADMIN_APP" | jq -r '.id')
stored "$ADMIN_ID"
show -X POST "$BASE_URL/api/v2/oauth2-provider/apps/$ADMIN_ID/secrets" -H "$AUTH_HEADER"
```

```text
confidential | client_secret_post
HTTP 201
{
  "id": "a77ab276-ea74-4711-ba8b-955a8cb97951",
  "client_secret_full": "coder_eGlt04LhYg_<redacted>"
}
```

Together with scenario 1 this brackets the guard: it fires for a
dynamically registered public client and for nothing else. Note the
admin API stores `client_secret_post`, not the RFC 7591 section 2
default, so every admin-created app is an agreement case for scenario 5.
Such apps carry no registration access token, so they cannot reach the
RFC 7592 endpoints where the reporting change applies at all.

</details>

<details>
<summary>5. Agreement cases report the stored value unchanged</summary>

The `client_secret_post` case is the one that matters. An implementation
that substituted the type default on every call would still pass the
public case, since `none` is the public default, but would rewrite this
client to `client_secret_basic` and tell it to send its secret in the
wrong place.

```bash
curl -s "$BASE_URL/oauth2/clients/$PUB_ID" -H "Authorization: Bearer $PUB_RAT" \
  | jq -c '{reported: .token_endpoint_auth_method}'

POST_REG=$(register manual-28097-post client_secret_post)
POST_ID=$(echo "$POST_REG" | jq -r '.client_id')
echo "$POST_REG" | jq -c '{reported_on_register: .token_endpoint_auth_method}'
curl -s "$BASE_URL/oauth2/clients/$POST_ID" -H "Authorization: Bearer $POST_RAT" \
  | jq -c '.token_endpoint_auth_method'
stored "$POST_ID"
```

```text
{"reported":"none"}
{"reported_on_register":"client_secret_post"}
"client_secret_post"
confidential | client_secret_post
```

Registration and read both report the stored value. The update site is
covered by scenarios 8 and 9.

</details>

<details>
<summary>6. A legacy confidential row storing `none` reports
`client_secret_basic`</summary>

Seeded from a real confidential client so it genuinely holds the secret
its exchange requires, with only the method column rewritten. This is
the pre-#28043 shape and cannot be produced through the API any more.

```bash
LEGACY=$(register manual-28097-legacy "")
LEGACY_ID=$(echo "$LEGACY" | jq -r '.client_id')
LEGACY_SECRET=$(echo "$LEGACY" | jq -r '.client_secret')
stored "$LEGACY_ID"

psql "$PGURL" -c "update oauth2_provider_apps set token_endpoint_auth_method = 'none'
  where id = '$LEGACY_ID';"
stored "$LEGACY_ID"
psql "$PGURL" -At -c "select count(*) from oauth2_provider_app_secrets where app_id = '$LEGACY_ID';"

curl -s "$BASE_URL/oauth2/clients/$LEGACY_ID" -H "Authorization: Bearer $LEGACY_RAT" \
  | jq -c '{reported: .token_endpoint_auth_method}'
stored "$LEGACY_ID"
```

```text
confidential | client_secret_basic
UPDATE 1
confidential | none
1
{"reported":"client_secret_basic"}
confidential | none
```

The response substitutes and the row is deliberately not rewritten. A
read has no side effects.

</details>

<details>
<summary>7. The reported method is the one actually enforced</summary>

The token endpoint enforces on `client_type`, which is still
confidential, so the secret is required regardless of what the method
column says.

```bash
exchange "$LEGACY_ID" "$LEGACY_SECRET" | jq -c '{has_access: has("access_token"), error, error_description}'
exchange "$LEGACY_ID" ""               | jq -c '{has_access: has("access_token"), error, error_description}'
```

```text
{"has_access":true,"error":null,"error_description":null}
{"has_access":false,"error":"invalid_request","error_description":"Missing required parameter: client_secret"}
```

The second line is the pre-fix breakage reproduced. A client that read
`"token_endpoint_auth_method": "none"` from `GET` and dropped its secret
accordingly, which is what RFC 7592 tells it to do, would have hit
exactly this on its next exchange. The old response was not internally
inconsistent, it was actionable and wrong.

Scenario 10 shows the same property in the opposite direction.

</details>

<details>
<summary>8. An update resending the stored value is accepted and changes
nothing</summary>

```bash
show -X PUT "$BASE_URL/oauth2/clients/$LEGACY_ID" \
  -H "Authorization: Bearer $LEGACY_RAT" -H "Content-Type: application/json" \
  -d '{"client_name":"manual-28097-legacy","redirect_uris":["http://localhost:9876/callback"],"token_endpoint_auth_method":"none"}'
stored "$LEGACY_ID"
```

```text
HTTP 200
  "token_endpoint_auth_method": "client_secret_basic",
confidential | none
```

Three things at once. The update is accepted, which is why the
type-change guard requires the auth method to actually change: the
requested `none` implies a public client while the row is confidential,
so a guard keyed on the type mismatch alone would reject this and lock a
legacy client out of managing its own registration. The `PUT` reports
the same substituted value as the `GET`, covering the third call site.
The row keeps what the client sent, so the divergence persists until
scenario 9.

</details>

<details>
<summary>9. An update resending the reported value heals the
row</summary>

```bash
show -X PUT "$BASE_URL/oauth2/clients/$LEGACY_ID" \
  -H "Authorization: Bearer $LEGACY_RAT" -H "Content-Type: application/json" \
  -d '{"client_name":"manual-28097-legacy","redirect_uris":["http://localhost:9876/callback"],"token_endpoint_auth_method":"client_secret_basic"}'
stored "$LEGACY_ID"
curl -s "$BASE_URL/oauth2/clients/$LEGACY_ID" -H "Authorization: Bearer $LEGACY_RAT" \
  | jq -c '{reported: .token_endpoint_auth_method}'
exchange "$LEGACY_ID" "$LEGACY_SECRET" | jq -c '{has_access: has("access_token")}'
```

```text
HTTP 200
  "token_endpoint_auth_method": "client_secret_basic",
confidential | client_secret_basic
{"reported":"client_secret_basic"}
{"has_access":true}
```

The row healed through an ordinary read-modify-write cycle, with no
migration, backfill, or admin action. That works only because scenario 8
keeps the door open and this response gives the client a correct value
to echo back; remove either and the row stays inconsistent indefinitely.

</details>

<details>
<summary>10. The reverse mismatch reports `none`</summary>

Registration cannot produce this direction either, but
`reportedAuthMethod` branches on the general disagreement rather than
the one shape known to exist, so it is covered.

```bash
REVERSE=$(register manual-28097-reverse none)
REVERSE_ID=$(echo "$REVERSE" | jq -r '.client_id')
psql "$PGURL" -c "update oauth2_provider_apps set token_endpoint_auth_method = 'client_secret_basic'
  where id = '$REVERSE_ID';"
stored "$REVERSE_ID"
curl -s "$BASE_URL/oauth2/clients/$REVERSE_ID" -H "Authorization: Bearer $REVERSE_RAT" \
  | jq -c '{reported: .token_endpoint_auth_method}'
exchange "$REVERSE_ID" "" | jq -c '{has_access: has("access_token"), error}'
```

```text
public | client_secret_basic
{"reported":"none"}
{"has_access":true,"error":null}
```

This client has no secret row at all and the token endpoint does not ask
for one, so `none` is what the response should say. Reporting the stored
`client_secret_basic` would have instructed it to send a secret that
does not exist.

Both resend shapes behave symmetrically with scenarios 8 and 9:

```text
resend stored (client_secret_basic) -> reported "none", row unchanged
resend reported (none)              -> reported "none", row now public | none
```

</details>

<details>
<summary>11. Empty or unrecognized stored methods fall back to the
default</summary>

`NULL` and `''` are indistinguishable once read into `sql.NullString`. A
third case was added because the function gates on validity rather than
emptiness.

```bash
for v in "null" "''" "'private_key_jwt'"; do
  psql "$PGURL" -At -c "update oauth2_provider_apps set token_endpoint_auth_method = $v where id = '$CONF_ID';"
  stored "$CONF_ID"
  curl -s "$BASE_URL/oauth2/clients/$CONF_ID" -H "Authorization: Bearer $CONF_RAT" \
    | jq -c '.token_endpoint_auth_method'
done
```

```text
confidential | <NULL>
"client_secret_basic"
confidential |
"client_secret_basic"
confidential | private_key_jwt
"client_secret_basic"
```

`private_key_jwt` is a real RFC 7591 method that Coder does not
implement. Reporting it back would advertise an authentication scheme
the token endpoint cannot honor, which is the same class of problem as
the legacy `none` report in scenario 7.

</details>

<details>
<summary>12. Type-changing updates are rejected both ways</summary>

```bash
show -X PUT "$BASE_URL/oauth2/clients/$CONF_ID" \
  -H "Authorization: Bearer $CONF_RAT" -H "Content-Type: application/json" \
  -d '{"client_name":"manual-28097-confidential","redirect_uris":["http://localhost:9876/callback"],"token_endpoint_auth_method":"none"}'
stored "$CONF_ID"

show -X PUT "$BASE_URL/oauth2/clients/$PUB_ID" \
  -H "Authorization: Bearer $PUB_RAT" -H "Content-Type: application/json" \
  -d '{"client_name":"manual-28097-public","redirect_uris":["http://localhost:9876/callback"],"token_endpoint_auth_method":"client_secret_basic"}'
stored "$PUB_ID"

show -X PUT "$BASE_URL/oauth2/clients/$CONF_ID" \
  -H "Authorization: Bearer $CONF_RAT" -H "Content-Type: application/json" \
  -d '{"client_name":"manual-28097-confidential","redirect_uris":["http://localhost:9876/callback"],"token_endpoint_auth_method":"client_secret_post"}'
stored "$CONF_ID"
```

```text
HTTP 400
{
  "error": "invalid_client_metadata",
  "error_description": "token_endpoint_auth_method cannot move an existing client between public and confidential (stored \"client_secret_basic\", requested \"none\"); the client type is fixed at registration, so register a new client instead"
}
confidential | client_secret_basic

HTTP 400
{
  "error": "invalid_client_metadata",
  "error_description": "token_endpoint_auth_method cannot move an existing client between public and confidential (stored \"none\", requested \"client_secret_basic\"); the client type is fixed at registration, so register a new client instead"
}
public | none

HTTP 200
  "token_endpoint_auth_method": "client_secret_post",
confidential | client_secret_post
```

Both rejections leave the row and its secrets untouched. A partial
application would be the dangerous outcome here, a client left
confidential while its caller believes it went public.

The third case is the control. Two `400`s alone would be equally
consistent with a guard that rejects every `token_endpoint_auth_method`
change, a considerably more disruptive rule than the documented one. The
`200` pins the guard to the derived client type rather than the method
string.

The second case is also what backs scenario 1. If public to confidential
were permitted, the workaround to a refused secret request would be to
flip the type and ask again. The two guards close that loop, which is
why the same remedy appears in both error messages.

</details>

<details>
<summary>13. Regression sweep of the merged stack</summary>

Nothing here is new in this PR, but the guards sit on top of it.

```text
discovery token_endpoint_auth_methods_supported : ["client_secret_basic","client_secret_post","none"]
public registration, client_secret key present  : false
confidential registration, secret issued        : true, method defaulted to client_secret_basic
PKCE-only exchange, no client_secret sent       : access + refresh issued
access token against /api/v2/users/me           : 200
token row app_id / app_secret_id                : populated / NULL
RFC 7009 revoke of own refresh token            : 200, access token then 401
authorized-apps listing while a token is live   : [{"name":"manual-28097-public"}]
bulk DELETE /oauth2/tokens                      : 204, listing then []
```

The NULL `app_secret_id` is what makes the secrets guard necessary. That
column is `ON DELETE CASCADE`, so deleting a confidential app's secret
takes its tokens with it, while a public client's tokens would survive.
An admin who deleted such a secret would believe access was cut off when
it was not.

PKCE failure modes were checked separately, since the token endpoint
distinguishes two the previous runbook treated as one:

```text
verifier omitted                     : invalid_request, RFC 7636 section 4.1 bounds
well-formed 43 chars but wrong       : invalid_grant, "The PKCE code verifier is invalid"
correct verifier, replaying that code: invalid_grant, "invalid or expired"
```

The third confirms the failed check destroys the code, so a leaked code
cannot absorb repeated verifier guesses.

</details>

<details>
<summary>14. The new docs paragraphs match observed behavior</summary>

`pnpm run lint-docs` reports 0 errors across 501 files, `pnpm run
format-docs` rewrites nothing, and Vale reports 0 errors with 2
warnings, both on pre-existing gerund headings that the same file on
`main` also produces. The new prose is one sentence per line.

| Documented claim | Verified by |
|---|---|
| A client's type is fixed when it registers | 12 |
| A type-changing update is rejected with `invalid_client_metadata` |
12, both directions |
| The client either holds a secret that would stop being required or has
none and no way to be issued one | 12 (2 secrets), 1 and 12 (0 secrets,
issuance refused) |
| Switching between `client_secret_basic` and `client_secret_post` is
allowed | 12 |
| To change type, register a new client | matches the remedy in both
errors and in scenario 1's detail |
| Legacy `none` clients are stored as confidential and still require
their `client_secret` | 6, 7 |
| Coder reports `client_secret_basic` for those clients | 6 |
| So that what it reports matches what it enforces | 7, both directions
|
| The mismatch clears itself the next time the client updates its
registration | 9 |

One wording note. Scenario 8 shows the mismatch does not clear on an
update that resends the stored value, so strictly it clears on the next
update carrying the reported value. A read-modify-write client, which is
what RFC 7592 section 2.2 prescribes, always carries the reported value,
so the sentence holds for the client it describes. A client that
hardcodes its own metadata would not self-heal, but it would also not be
following RFC 7592.

</details>

<details>
<summary>Cleanup</summary>

```bash
for id in "$PUB_ID" "$CONF_ID" "$POST_ID" "$LEGACY_ID" "$REVERSE_ID" "$ADMIN_ID"; do
  curl -s -X DELETE "$BASE_URL/api/v2/oauth2-provider/apps/$id" -H "$AUTH_HEADER" \
    -o /dev/null -w "%{http_code}\n"
done
curl -s -X PUT "$BASE_URL/api/v2/oauth2-provider/settings" -H "$AUTH_HEADER" \
  -H "Content-Type: application/json" -d '{"dynamic_client_registration_enabled": false}'
show -X POST "$BASE_URL/oauth2/register" -H "Content-Type: application/json" \
  -d '{"client_name":"should-fail","redirect_uris":["http://localhost:9876/callback"],"token_endpoint_auth_method":"none"}'
```

```text
204 (x6)
{"dynamic_client_registration_enabled":false}
HTTP 403
{"error":"invalid_request","error_description":"Dynamic client registration is disabled on this deployment"}
```

All six test apps deleted with no orphaned secret or token rows. Both
seeded rows had already healed to a consistent state before deletion.
DCR is back off, confirmed by a registration attempt rather than by
reading the flag back.

</details>
2026-09-01 08:58:01 -07:00

218 KiB
Generated

title
title
Enterprise

OAuth2 authorization server metadata

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/.well-known/oauth-authorization-server \
  -H 'Accept: application/json'

GET /.well-known/oauth-authorization-server

Example responses

200 Response

{
  "authorization_endpoint": "string",
  "code_challenge_methods_supported": [
    "S256"
  ],
  "grant_types_supported": [
    "authorization_code"
  ],
  "issuer": "string",
  "registration_endpoint": "string",
  "response_types_supported": [
    "code"
  ],
  "revocation_endpoint": "string",
  "scopes_supported": [
    "string"
  ],
  "token_endpoint": "string",
  "token_endpoint_auth_methods_supported": [
    "client_secret_basic"
  ]
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.OAuth2AuthorizationServerMetadata

OAuth2 protected resource metadata

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/.well-known/oauth-protected-resource \
  -H 'Accept: application/json'

GET /.well-known/oauth-protected-resource

Example responses

200 Response

{
  "authorization_servers": [
    "string"
  ],
  "bearer_methods_supported": [
    "string"
  ],
  "resource": "string",
  "scopes_supported": [
    "string"
  ]
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.OAuth2ProtectedResourceMetadata

Get agent firewall session by ID

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/agent-firewall/sessions/{id} \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/agent-firewall/sessions/{id}

Parameters

Name In Type Required Description
id path string(uuid) true Agent firewall session ID

Example responses

200 Response

{
  "confined_process": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "owner_id": "8826ee2e-7933-4665-aef2-2393f84a0d05",
  "started_at": "2019-08-24T14:15:22Z",
  "workspace_id": "0967198e-ec7b-4c6b-b4d3-f71244cadbe9"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.AgentFirewallSession

To perform this operation, you must be authenticated. Learn more.

Get agent firewall session logs

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/agent-firewall/sessions/{id}/logs \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/agent-firewall/sessions/{id}/logs

Parameters

Name In Type Required Description
id path string(uuid) true Agent firewall session ID
seq_after query integer false Inclusive lower bound on sequence number
seq_before query integer false Exclusive upper bound on sequence number
limit query integer false Maximum number of logs to return (default 100)

Example responses

200 Response

{
  "results": [
    {
      "allowed": true,
      "captured_at": "2019-08-24T14:15:22Z",
      "created_at": "2019-08-24T14:15:22Z",
      "detail": "string",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "matched_rule": "string",
      "method": "string",
      "proto": "string",
      "sequence_number": 0,
      "session_id": "1ffd059c-17ea-40a8-8aef-70fd0307db82"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.AgentFirewallSessionLogsResponse

To perform this operation, you must be authenticated. Learn more.

List AI Gateway keys

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/ai-gateway/keys \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/ai-gateway/keys

Example responses

200 Response

[
  {
    "created_at": "2019-08-24T14:15:22Z",
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "key_prefix": "string",
    "last_heartbeat_at": "2019-08-24T14:15:22Z",
    "name": "string"
  }
]

Responses

Status Meaning Description Schema
200 OK OK array of codersdk.AIGatewayKey

Response Schema

Status Code 200

Name Type Required Restrictions Description
[array item] array false
» created_at string(date-time) false
» id string(uuid) false
» key_prefix string false
» last_heartbeat_at string(date-time) false
» name string false

To perform this operation, you must be authenticated. Learn more.

Create AI Gateway key

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/ai-gateway/keys \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

POST /api/v2/ai-gateway/keys

Body parameter

{
  "name": "string"
}

Parameters

Name In Type Required Description
body body codersdk.CreateAIGatewayKeyRequest true Create AI Gateway key request

Example responses

201 Response

{
  "created_at": "2019-08-24T14:15:22Z",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "key": "string",
  "key_prefix": "string",
  "name": "string"
}

Responses

Status Meaning Description Schema
201 Created Created codersdk.CreateAIGatewayKeyResponse

To perform this operation, you must be authenticated. Learn more.

Delete AI Gateway key

Code samples

# Example request using curl
curl -X DELETE http://coder-server:8080/api/v2/ai-gateway/keys/{key} \
  -H 'Coder-Session-Token: API_KEY'

DELETE /api/v2/ai-gateway/keys/{key}

Parameters

Name In Type Required Description
key path string(uuid) true Key ID

Responses

Status Meaning Description Schema
204 No Content No Content

To perform this operation, you must be authenticated. Learn more.

AI Gateway serve

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/ai-gateway/serve \
  -H 'X-AI-Governance-Gateway-Key: API_KEY'

GET /api/v2/ai-gateway/serve

Responses

Status Meaning Description Schema
101 Switching Protocols Switching Protocols

To perform this operation, you must be authenticated. Learn more.

Get appearance

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/appearance \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/appearance

Example responses

200 Response

{
  "announcement_banners": [
    {
      "background_color": "string",
      "enabled": true,
      "message": "string"
    }
  ],
  "application_name": "string",
  "docs_url": "string",
  "logo_url": "string",
  "service_banner": {
    "background_color": "string",
    "enabled": true,
    "message": "string"
  },
  "support_links": [
    {
      "icon": "bug",
      "location": "navbar",
      "name": "string",
      "target": "string"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.AppearanceConfig

To perform this operation, you must be authenticated. Learn more.

Update appearance

Code samples

# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/appearance \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PUT /api/v2/appearance

Body parameter

{
  "announcement_banners": [
    {
      "background_color": "string",
      "enabled": true,
      "message": "string"
    }
  ],
  "application_name": "string",
  "logo_url": "string",
  "service_banner": {
    "background_color": "string",
    "enabled": true,
    "message": "string"
  }
}

Parameters

Name In Type Required Description
body body codersdk.UpdateAppearanceConfig true Update appearance request

Example responses

200 Response

{
  "announcement_banners": [
    {
      "background_color": "string",
      "enabled": true,
      "message": "string"
    }
  ],
  "application_name": "string",
  "logo_url": "string",
  "service_banner": {
    "background_color": "string",
    "enabled": true,
    "message": "string"
  }
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.UpdateAppearanceConfig

To perform this operation, you must be authenticated. Learn more.

Get connection logs

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/connectionlog?limit=0 \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/connectionlog

Parameters

Name In Type Required Description
q query string false Search query
limit query integer true Page limit
offset query integer false Page offset

Example responses

200 Response

{
  "connection_logs": [
    {
      "agent_name": "string",
      "connect_time": "2019-08-24T14:15:22Z",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "ip": "string",
      "organization": {
        "display_name": "string",
        "icon": "string",
        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        "name": "string"
      },
      "ssh_info": {
        "connection_id": "d3547de1-d1f2-4344-b4c2-17169b7526f9",
        "disconnect_reason": "string",
        "disconnect_time": "2019-08-24T14:15:22Z",
        "exit_code": 0
      },
      "type": "ssh",
      "web_info": {
        "slug_or_port": "string",
        "status_code": 0,
        "user": {
          "avatar_url": "http://example.com",
          "created_at": "2019-08-24T14:15:22Z",
          "email": "user@example.com",
          "has_ai_seat": true,
          "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
          "is_service_account": true,
          "last_seen_at": "2019-08-24T14:15:22Z",
          "login_type": "",
          "name": "string",
          "organization_ids": [
            "497f6eca-6276-4993-bfeb-53cbbbba6f08"
          ],
          "roles": [
            {
              "display_name": "string",
              "name": "string",
              "organization_id": "string"
            }
          ],
          "status": "active",
          "theme_preference": "string",
          "updated_at": "2019-08-24T14:15:22Z",
          "username": "string"
        },
        "user_agent": "string"
      },
      "workspace_id": "0967198e-ec7b-4c6b-b4d3-f71244cadbe9",
      "workspace_name": "string",
      "workspace_owner_id": "e7078695-5279-4c86-8774-3ac2367a2fc7",
      "workspace_owner_username": "string"
    }
  ],
  "count": 0,
  "count_cap": 0
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.ConnectionLogResponse

To perform this operation, you must be authenticated. Learn more.

Report a premium paywall click

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/deployment/premium-funnel-events \
  -H 'Content-Type: application/json' \
  -H 'Coder-Session-Token: API_KEY'

POST /api/v2/deployment/premium-funnel-events

Body parameter

{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "source": "aibridge_session_threads",
  "variant": "premium"
}

Parameters

Name In Type Required Description
body body codersdk.PremiumFunnelEventRequest true Premium funnel event

Responses

Status Meaning Description Schema
204 No Content No Content

To perform this operation, you must be authenticated. Learn more.

Get entitlements

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/entitlements \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/entitlements

Example responses

200 Response

{
  "errors": [
    "string"
  ],
  "features": {
    "property1": {
      "actual": 0,
      "actual_ms": 0,
      "enabled": true,
      "entitlement": "entitled",
      "hard_limit": 0,
      "limit": 0,
      "soft_limit": 0,
      "usage_period": {
        "end": "2019-08-24T14:15:22Z",
        "issued_at": "2019-08-24T14:15:22Z",
        "start": "2019-08-24T14:15:22Z"
      }
    },
    "property2": {
      "actual": 0,
      "actual_ms": 0,
      "enabled": true,
      "entitlement": "entitled",
      "hard_limit": 0,
      "limit": 0,
      "soft_limit": 0,
      "usage_period": {
        "end": "2019-08-24T14:15:22Z",
        "issued_at": "2019-08-24T14:15:22Z",
        "start": "2019-08-24T14:15:22Z"
      }
    }
  },
  "has_license": true,
  "refreshed_at": "2019-08-24T14:15:22Z",
  "require_telemetry": true,
  "trial": true,
  "warnings": [
    "string"
  ]
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.Entitlements

To perform this operation, you must be authenticated. Learn more.

Get groups

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/groups?organization=string&has_member=string&group_ids=string \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/groups

Parameters

Name In Type Required Description
organization query string true Organization ID or name
has_member query string true User ID or name
group_ids query string true Comma separated list of group IDs

Example responses

200 Response

[
  {
    "avatar_url": "http://example.com",
    "display_name": "string",
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "members": [
      {
        "avatar_url": "http://example.com",
        "created_at": "2019-08-24T14:15:22Z",
        "email": "user@example.com",
        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        "is_service_account": true,
        "last_seen_at": "2019-08-24T14:15:22Z",
        "login_type": "",
        "name": "string",
        "status": "active",
        "theme_preference": "string",
        "updated_at": "2019-08-24T14:15:22Z",
        "username": "string"
      }
    ],
    "name": "string",
    "organization_display_name": "string",
    "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
    "organization_name": "string",
    "quota_allowance": 0,
    "source": "user",
    "total_member_count": 0
  }
]

Responses

Status Meaning Description Schema
200 OK OK array of codersdk.Group

Response Schema

Status Code 200

Name Type Required Restrictions Description
[array item] array false
» avatar_url string(uri) false
» display_name string false
» id string(uuid) false
» members array false
»» avatar_url string(uri) false
»» created_at string(date-time) true
»» email string(email) true
»» id string(uuid) true
»» is_service_account boolean false
»» last_seen_at string(date-time) false
»» login_type codersdk.LoginType false
»» name string false
»» status codersdk.UserStatus false
»» theme_preference string false Deprecated: this value should be retrieved from codersdk.UserPreferenceSettings instead.
»» updated_at string(date-time) false
»» username string true
» name string false
» organization_display_name string false
» organization_id string(uuid) false
» organization_name string false
» quota_allowance integer false
» source codersdk.GroupSource false
» total_member_count integer false How many members are in this group. Shows the total count, even if the user is not authorized to read group member details. May be greater than len(Group.Members).

Enumerated Values

Property Value(s)
login_type ``, github, none, oidc, password, token
status active, suspended
source oidc, user

To perform this operation, you must be authenticated. Learn more.

Get group by ID

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/groups/{group} \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/groups/{group}

Parameters

Name In Type Required Description
group path string true Group id
exclude_members query boolean false Exclude members from the response

Example responses

200 Response

{
  "avatar_url": "http://example.com",
  "display_name": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "members": [
    {
      "avatar_url": "http://example.com",
      "created_at": "2019-08-24T14:15:22Z",
      "email": "user@example.com",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "is_service_account": true,
      "last_seen_at": "2019-08-24T14:15:22Z",
      "login_type": "",
      "name": "string",
      "status": "active",
      "theme_preference": "string",
      "updated_at": "2019-08-24T14:15:22Z",
      "username": "string"
    }
  ],
  "name": "string",
  "organization_display_name": "string",
  "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
  "organization_name": "string",
  "quota_allowance": 0,
  "source": "user",
  "total_member_count": 0
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.Group

To perform this operation, you must be authenticated. Learn more.

Delete group by name

Code samples

# Example request using curl
curl -X DELETE http://coder-server:8080/api/v2/groups/{group} \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

DELETE /api/v2/groups/{group}

Parameters

Name In Type Required Description
group path string true Group name

Example responses

200 Response

{
  "avatar_url": "http://example.com",
  "display_name": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "members": [
    {
      "avatar_url": "http://example.com",
      "created_at": "2019-08-24T14:15:22Z",
      "email": "user@example.com",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "is_service_account": true,
      "last_seen_at": "2019-08-24T14:15:22Z",
      "login_type": "",
      "name": "string",
      "status": "active",
      "theme_preference": "string",
      "updated_at": "2019-08-24T14:15:22Z",
      "username": "string"
    }
  ],
  "name": "string",
  "organization_display_name": "string",
  "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
  "organization_name": "string",
  "quota_allowance": 0,
  "source": "user",
  "total_member_count": 0
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.Group

To perform this operation, you must be authenticated. Learn more.

Update group by name

Code samples

# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/groups/{group} \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PATCH /api/v2/groups/{group}

Body parameter

{
  "add_users": [
    "string"
  ],
  "avatar_url": "string",
  "display_name": "string",
  "name": "string",
  "quota_allowance": 0,
  "remove_users": [
    "string"
  ]
}

Parameters

Name In Type Required Description
group path string true Group name
body body codersdk.PatchGroupRequest true Patch group request

Example responses

200 Response

{
  "avatar_url": "http://example.com",
  "display_name": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "members": [
    {
      "avatar_url": "http://example.com",
      "created_at": "2019-08-24T14:15:22Z",
      "email": "user@example.com",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "is_service_account": true,
      "last_seen_at": "2019-08-24T14:15:22Z",
      "login_type": "",
      "name": "string",
      "status": "active",
      "theme_preference": "string",
      "updated_at": "2019-08-24T14:15:22Z",
      "username": "string"
    }
  ],
  "name": "string",
  "organization_display_name": "string",
  "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
  "organization_name": "string",
  "quota_allowance": 0,
  "source": "user",
  "total_member_count": 0
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.Group

To perform this operation, you must be authenticated. Learn more.

Get group AI budget

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/groups/{group}/ai/budget \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/groups/{group}/ai/budget

Parameters

Name In Type Required Description
group path string(uuid) true Group ID

Example responses

200 Response

{
  "created_at": "2019-08-24T14:15:22Z",
  "group_id": "306db4e0-7449-4501-b76f-075576fe2d8f",
  "spend_limit_micros": 0,
  "updated_at": "2019-08-24T14:15:22Z"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.GroupAIBudget

To perform this operation, you must be authenticated. Learn more.

Upsert group AI budget

Code samples

# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/groups/{group}/ai/budget \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PUT /api/v2/groups/{group}/ai/budget

Body parameter

{
  "spend_limit_micros": 0
}

Parameters

Name In Type Required Description
group path string(uuid) true Group ID
body body codersdk.UpsertGroupAIBudgetRequest true Upsert group AI budget request

Example responses

200 Response

{
  "created_at": "2019-08-24T14:15:22Z",
  "group_id": "306db4e0-7449-4501-b76f-075576fe2d8f",
  "spend_limit_micros": 0,
  "updated_at": "2019-08-24T14:15:22Z"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.GroupAIBudget

To perform this operation, you must be authenticated. Learn more.

Delete group AI budget

Code samples

# Example request using curl
curl -X DELETE http://coder-server:8080/api/v2/groups/{group}/ai/budget \
  -H 'Coder-Session-Token: API_KEY'

DELETE /api/v2/groups/{group}/ai/budget

Parameters

Name In Type Required Description
group path string(uuid) true Group ID

Responses

Status Meaning Description Schema
204 No Content No Content

To perform this operation, you must be authenticated. Learn more.

Get group AI spend

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/groups/{group}/ai/spend \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/groups/{group}/ai/spend

Returns the AI spend limit and aggregate spend for the group.

Parameters

Name In Type Required Description
group path string(uuid) true Group ID

Example responses

200 Response

{
  "current_spend_micros": 0,
  "group_id": "306db4e0-7449-4501-b76f-075576fe2d8f",
  "period_end": "2019-08-24T14:15:22Z",
  "period_start": "2019-08-24T14:15:22Z",
  "spend_limit_micros": 0,
  "total_spend_limit_micros": 0
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.GroupAISpend

To perform this operation, you must be authenticated. Learn more.

Get group members by group ID

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/groups/{group}/members \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/groups/{group}/members

Parameters

Name In Type Required Description
group path string true Group id
q query string false Member search query
after_id query string(uuid) false After ID
limit query integer false Page limit
offset query integer false Page offset

Example responses

200 Response

{
  "count": 0,
  "users": [
    {
      "avatar_url": "http://example.com",
      "created_at": "2019-08-24T14:15:22Z",
      "email": "user@example.com",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "is_service_account": true,
      "last_seen_at": "2019-08-24T14:15:22Z",
      "login_type": "",
      "name": "string",
      "status": "active",
      "theme_preference": "string",
      "updated_at": "2019-08-24T14:15:22Z",
      "username": "string"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.GroupMembersResponse

To perform this operation, you must be authenticated. Learn more.

Get group members AI spend

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/groups/{group}/members/ai/spend?user_ids=string \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/groups/{group}/members/ai/spend

Returns aggregate AI spend attributed to the group per requested user. A maximum of 100 user IDs may be requested per call, and requests with more are rejected, so callers are expected to batch across multiple requests. User IDs that are not members of the group, or that the caller has no read access to, are silently omitted.

Parameters

Name In Type Required Description
group path string(uuid) true Group ID
user_ids query string true Comma-separated list of user IDs (maximum 100)

Example responses

200 Response

{
  "members": [
    {
      "effective_budget": {
        "limit_source": "user_override",
        "spend_limit_micros": 0
      },
      "effective_group_id": "85e2b926-ddfb-4c66-b68e-b66e5acec6c0",
      "group_budget": {
        "limit_source": "user_override",
        "spend_limit_micros": 0
      },
      "group_spend_micros": 0,
      "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5"
    }
  ],
  "period_end": "2019-08-24T14:15:22Z",
  "period_start": "2019-08-24T14:15:22Z"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.GroupMembersAISpend

To perform this operation, you must be authenticated. Learn more.

Get licenses

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/licenses \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/licenses

Example responses

200 Response

[
  {
    "claims": {},
    "id": 0,
    "uploaded_at": "2019-08-24T14:15:22Z",
    "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f"
  }
]

Responses

Status Meaning Description Schema
200 OK OK array of codersdk.License

Response Schema

Status Code 200

Name Type Required Restrictions Description
[array item] array false
» claims object false Claims are the JWT claims asserted by the license. Here we use a generic string map to ensure that all data from the server is parsed verbatim, not just the fields this version of Coder understands.
» id integer false
» uploaded_at string(date-time) false
» uuid string(uuid) false

To perform this operation, you must be authenticated. Learn more.

Add new license

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/licenses \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

POST /api/v2/licenses

Body parameter

{
  "license": "string"
}

Parameters

Name In Type Required Description
body body codersdk.AddLicenseRequest true Add license request

Example responses

201 Response

{
  "claims": {},
  "id": 0,
  "uploaded_at": "2019-08-24T14:15:22Z",
  "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f"
}

Responses

Status Meaning Description Schema
201 Created Created codersdk.License

To perform this operation, you must be authenticated. Learn more.

Update license entitlements

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/licenses/refresh-entitlements \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

POST /api/v2/licenses/refresh-entitlements

Example responses

201 Response

{
  "detail": "string",
  "message": "string",
  "validations": [
    {
      "detail": "string",
      "field": "string"
    }
  ]
}

Responses

Status Meaning Description Schema
201 Created Created codersdk.Response

To perform this operation, you must be authenticated. Learn more.

Request a trial license

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/licenses/trial \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

POST /api/v2/licenses/trial

Body parameter

{
  "attribution_id": "6f882a62-1d45-46e1-b5f4-0abfea127010",
  "company_name": "Acme Corp",
  "country": "United States",
  "developers": "string",
  "email": "jane.doe@example.com",
  "first_name": "Jane",
  "job_title": "Engineering Manager",
  "last_name": "Doe",
  "phone_number": "+14155552671",
  "source": "aibridge_session_threads"
}

Parameters

Name In Type Required Description
body body codersdk.CreateTrialLicenseRequest true Trial license request

Example responses

201 Response

{
  "claims": {},
  "id": 0,
  "uploaded_at": "2019-08-24T14:15:22Z",
  "uuid": "095be615-a8ad-4c33-8e9c-c7612fbf6c9f"
}

Responses

Status Meaning Description Schema
201 Created Created codersdk.License

To perform this operation, you must be authenticated. Learn more.

Delete license

Code samples

# Example request using curl
curl -X DELETE http://coder-server:8080/api/v2/licenses/{id} \
  -H 'Coder-Session-Token: API_KEY'

DELETE /api/v2/licenses/{id}

Parameters

Name In Type Required Description
id path string(number) true License ID

Responses

Status Meaning Description Schema
200 OK OK

To perform this operation, you must be authenticated. Learn more.

Update notification template dispatch method

Code samples

# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/notifications/templates/{notification_template}/method \
  -H 'Coder-Session-Token: API_KEY'

PUT /api/v2/notifications/templates/{notification_template}/method

Parameters

Name In Type Required Description
notification_template path string true Notification template UUID

Responses

Status Meaning Description Schema
200 OK Success
304 Not Modified Not modified

To perform this operation, you must be authenticated. Learn more.

Get OAuth2 applications

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/oauth2-provider/apps \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/oauth2-provider/apps

Parameters

Name In Type Required Description
user_id query string false Filter by applications authorized for a user

Example responses

200 Response

[
  {
    "callback_url": "string",
    "endpoints": {
      "authorization": "string",
      "device_authorization": "string",
      "token": "string",
      "token_revoke": "string"
    },
    "icon": "string",
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "name": "string"
  }
]

Responses

Status Meaning Description Schema
200 OK OK array of codersdk.OAuth2ProviderApp

Response Schema

Status Code 200

Name Type Required Restrictions Description
[array item] array false
» callback_url string false
» endpoints codersdk.OAuth2AppEndpoints false Endpoints are included in the app response for easier discovery. The OAuth2 spec does not have a defined place to find these (for comparison, OIDC has a '/.well-known/openid-configuration' endpoint).
»» authorization string false
»» device_authorization string false Device authorization is optional.
»» token string false
»» token_revoke string false
» icon string false
» id string(uuid) false
» name string false

To perform this operation, you must be authenticated. Learn more.

Create OAuth2 application

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/oauth2-provider/apps \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

POST /api/v2/oauth2-provider/apps

Body parameter

{
  "callback_url": "string",
  "icon": "string",
  "name": "string"
}

Parameters

Name In Type Required Description
body body codersdk.PostOAuth2ProviderAppRequest true The OAuth2 application to create.

Example responses

200 Response

{
  "callback_url": "string",
  "endpoints": {
    "authorization": "string",
    "device_authorization": "string",
    "token": "string",
    "token_revoke": "string"
  },
  "icon": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "name": "string"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.OAuth2ProviderApp

To perform this operation, you must be authenticated. Learn more.

Get OAuth2 application

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/oauth2-provider/apps/{app} \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/oauth2-provider/apps/{app}

Parameters

Name In Type Required Description
app path string true App ID

Example responses

200 Response

{
  "callback_url": "string",
  "endpoints": {
    "authorization": "string",
    "device_authorization": "string",
    "token": "string",
    "token_revoke": "string"
  },
  "icon": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "name": "string"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.OAuth2ProviderApp

To perform this operation, you must be authenticated. Learn more.

Update OAuth2 application

Code samples

# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/oauth2-provider/apps/{app} \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PUT /api/v2/oauth2-provider/apps/{app}

Body parameter

{
  "callback_url": "string",
  "icon": "string",
  "name": "string"
}

Parameters

Name In Type Required Description
app path string true App ID
body body codersdk.PutOAuth2ProviderAppRequest true Update an OAuth2 application.

Example responses

200 Response

{
  "callback_url": "string",
  "endpoints": {
    "authorization": "string",
    "device_authorization": "string",
    "token": "string",
    "token_revoke": "string"
  },
  "icon": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "name": "string"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.OAuth2ProviderApp

To perform this operation, you must be authenticated. Learn more.

Delete OAuth2 application

Code samples

# Example request using curl
curl -X DELETE http://coder-server:8080/api/v2/oauth2-provider/apps/{app} \
  -H 'Coder-Session-Token: API_KEY'

DELETE /api/v2/oauth2-provider/apps/{app}

Parameters

Name In Type Required Description
app path string true App ID

Responses

Status Meaning Description Schema
204 No Content No Content

To perform this operation, you must be authenticated. Learn more.

Get OAuth2 application secrets

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/oauth2-provider/apps/{app}/secrets \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/oauth2-provider/apps/{app}/secrets

Parameters

Name In Type Required Description
app path string true App ID

Example responses

200 Response

[
  {
    "client_secret_truncated": "string",
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "last_used_at": "string"
  }
]

Responses

Status Meaning Description Schema
200 OK OK array of codersdk.OAuth2ProviderAppSecret

Response Schema

Status Code 200

Name Type Required Restrictions Description
[array item] array false
» client_secret_truncated string false
» id string(uuid) false
» last_used_at string false

To perform this operation, you must be authenticated. Learn more.

Create OAuth2 application secret

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/oauth2-provider/apps/{app}/secrets \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

POST /api/v2/oauth2-provider/apps/{app}/secrets

Parameters

Name In Type Required Description
app path string true App ID

Example responses

200 Response

[
  {
    "client_secret_full": "string",
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  }
]

Responses

Status Meaning Description Schema
200 OK OK array of codersdk.OAuth2ProviderAppSecretFull
400 Bad Request Public clients cannot have secrets codersdk.Response

Response Schema

Status Code 200

Name Type Required Restrictions Description
[array item] array false
» client_secret_full string false
» id string(uuid) false

To perform this operation, you must be authenticated. Learn more.

Delete OAuth2 application secret

Code samples

# Example request using curl
curl -X DELETE http://coder-server:8080/api/v2/oauth2-provider/apps/{app}/secrets/{secretID} \
  -H 'Coder-Session-Token: API_KEY'

DELETE /api/v2/oauth2-provider/apps/{app}/secrets/{secretID}

Parameters

Name In Type Required Description
app path string true App ID
secretID path string true Secret ID

Responses

Status Meaning Description Schema
204 No Content No Content

To perform this operation, you must be authenticated. Learn more.

Get OAuth2 provider settings

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/oauth2-provider/settings \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/oauth2-provider/settings

Example responses

200 Response

{
  "dynamic_client_registration_enabled": true
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.OAuth2ProviderSettings

To perform this operation, you must be authenticated. Learn more.

Update OAuth2 provider settings

Code samples

# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/oauth2-provider/settings \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PUT /api/v2/oauth2-provider/settings

Body parameter

{
  "dynamic_client_registration_enabled": true
}

Parameters

Name In Type Required Description
body body codersdk.OAuth2ProviderSettings true OAuth2 provider settings request

Example responses

200 Response

{
  "dynamic_client_registration_enabled": true
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.OAuth2ProviderSettings

To perform this operation, you must be authenticated. Learn more.

Export organization AI spend as CSV

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/ai/spend/export \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/ai/spend/export

Returns per-user, per-group, per-model, per-provider aggregated AI spend for the organization as CSV, built from raw AI Gateway token usage. The optional period_start and period_end query parameters bound the period and are interpreted as UTC. They must be provided together and span at most 31 days. When both are omitted, the current UTC monthly period is used. An explicit period_start must fall within the configured AI Gateway data retention window, since older token usage is purged. The default period is narrowed to that window instead, and every row echoes the applied bounds. Requires organization-level administrator permissions.

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID
period_start query string(date-time) false Inclusive lower bound (RFC3339)
period_end query string(date-time) false Exclusive upper bound (RFC3339)

Responses

Status Meaning Description Schema
200 OK OK

To perform this operation, you must be authenticated. Learn more.

Get groups by organization

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/groups \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/groups

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID

Example responses

200 Response

[
  {
    "avatar_url": "http://example.com",
    "display_name": "string",
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "members": [
      {
        "avatar_url": "http://example.com",
        "created_at": "2019-08-24T14:15:22Z",
        "email": "user@example.com",
        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        "is_service_account": true,
        "last_seen_at": "2019-08-24T14:15:22Z",
        "login_type": "",
        "name": "string",
        "status": "active",
        "theme_preference": "string",
        "updated_at": "2019-08-24T14:15:22Z",
        "username": "string"
      }
    ],
    "name": "string",
    "organization_display_name": "string",
    "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
    "organization_name": "string",
    "quota_allowance": 0,
    "source": "user",
    "total_member_count": 0
  }
]

Responses

Status Meaning Description Schema
200 OK OK array of codersdk.Group

Response Schema

Status Code 200

Name Type Required Restrictions Description
[array item] array false
» avatar_url string(uri) false
» display_name string false
» id string(uuid) false
» members array false
»» avatar_url string(uri) false
»» created_at string(date-time) true
»» email string(email) true
»» id string(uuid) true
»» is_service_account boolean false
»» last_seen_at string(date-time) false
»» login_type codersdk.LoginType false
»» name string false
»» status codersdk.UserStatus false
»» theme_preference string false Deprecated: this value should be retrieved from codersdk.UserPreferenceSettings instead.
»» updated_at string(date-time) false
»» username string true
» name string false
» organization_display_name string false
» organization_id string(uuid) false
» organization_name string false
» quota_allowance integer false
» source codersdk.GroupSource false
» total_member_count integer false How many members are in this group. Shows the total count, even if the user is not authorized to read group member details. May be greater than len(Group.Members).

Enumerated Values

Property Value(s)
login_type ``, github, none, oidc, password, token
status active, suspended
source oidc, user

To perform this operation, you must be authenticated. Learn more.

Create group for organization

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/organizations/{organization}/groups \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

POST /api/v2/organizations/{organization}/groups

Body parameter

{
  "avatar_url": "string",
  "display_name": "string",
  "name": "string",
  "quota_allowance": 0
}

Parameters

Name In Type Required Description
organization path string true Organization ID
body body codersdk.CreateGroupRequest true Create group request

Example responses

201 Response

{
  "avatar_url": "http://example.com",
  "display_name": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "members": [
    {
      "avatar_url": "http://example.com",
      "created_at": "2019-08-24T14:15:22Z",
      "email": "user@example.com",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "is_service_account": true,
      "last_seen_at": "2019-08-24T14:15:22Z",
      "login_type": "",
      "name": "string",
      "status": "active",
      "theme_preference": "string",
      "updated_at": "2019-08-24T14:15:22Z",
      "username": "string"
    }
  ],
  "name": "string",
  "organization_display_name": "string",
  "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
  "organization_name": "string",
  "quota_allowance": 0,
  "source": "user",
  "total_member_count": 0
}

Responses

Status Meaning Description Schema
201 Created Created codersdk.Group

To perform this operation, you must be authenticated. Learn more.

Get organization groups AI spend

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/groups/ai/spend?group_ids=string \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/groups/ai/spend

Returns AI spend limits and aggregate spend for the requested groups. A maximum of 100 group IDs may be requested per call, and requests with more are rejected, so callers are expected to batch across multiple requests. Unknown or unreadable group IDs are silently omitted.

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID
group_ids query string true Comma-separated list of group IDs (maximum 100)

Example responses

200 Response

{
  "groups": [
    {
      "current_spend_micros": 0,
      "group_id": "306db4e0-7449-4501-b76f-075576fe2d8f",
      "spend_limit_micros": 0,
      "total_spend_limit_micros": 0
    }
  ],
  "period_end": "2019-08-24T14:15:22Z",
  "period_start": "2019-08-24T14:15:22Z"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.OrganizationGroupsAISpend

To perform this operation, you must be authenticated. Learn more.

Get group by organization and group name

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/groups/{groupName} \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/groups/{groupName}

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID
groupName path string true Group name

Example responses

200 Response

{
  "avatar_url": "http://example.com",
  "display_name": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "members": [
    {
      "avatar_url": "http://example.com",
      "created_at": "2019-08-24T14:15:22Z",
      "email": "user@example.com",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "is_service_account": true,
      "last_seen_at": "2019-08-24T14:15:22Z",
      "login_type": "",
      "name": "string",
      "status": "active",
      "theme_preference": "string",
      "updated_at": "2019-08-24T14:15:22Z",
      "username": "string"
    }
  ],
  "name": "string",
  "organization_display_name": "string",
  "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
  "organization_name": "string",
  "quota_allowance": 0,
  "source": "user",
  "total_member_count": 0
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.Group

To perform this operation, you must be authenticated. Learn more.

Get group members by organization and group name

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/groups/{groupName}/members \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/groups/{groupName}/members

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID
groupName path string true Group name
q query string false Member search query
after_id query string(uuid) false After ID
limit query integer false Page limit
offset query integer false Page offset

Example responses

200 Response

{
  "count": 0,
  "users": [
    {
      "avatar_url": "http://example.com",
      "created_at": "2019-08-24T14:15:22Z",
      "email": "user@example.com",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "is_service_account": true,
      "last_seen_at": "2019-08-24T14:15:22Z",
      "login_type": "",
      "name": "string",
      "status": "active",
      "theme_preference": "string",
      "updated_at": "2019-08-24T14:15:22Z",
      "username": "string"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.GroupMembersResponse

To perform this operation, you must be authenticated. Learn more.

Get group members AI spend by organization

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/groups/{groupName}/members/ai/spend?user_ids=string \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/groups/{groupName}/members/ai/spend

Returns aggregate AI spend attributed to the group per requested user. A maximum of 100 user IDs may be requested per call, and requests with more are rejected, so callers are expected to batch across multiple requests. User IDs that are not members of the group, or that the caller has no read access to, are silently omitted.

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID
groupName path string true Group name
user_ids query string true Comma-separated list of user IDs (maximum 100)

Example responses

200 Response

{
  "members": [
    {
      "effective_budget": {
        "limit_source": "user_override",
        "spend_limit_micros": 0
      },
      "effective_group_id": "85e2b926-ddfb-4c66-b68e-b66e5acec6c0",
      "group_budget": {
        "limit_source": "user_override",
        "spend_limit_micros": 0
      },
      "group_spend_micros": 0,
      "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5"
    }
  ],
  "period_end": "2019-08-24T14:15:22Z",
  "period_start": "2019-08-24T14:15:22Z"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.GroupMembersAISpend

To perform this operation, you must be authenticated. Learn more.

Get workspace quota by user

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/members/{user}/workspace-quota \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/members/{user}/workspace-quota

Parameters

Name In Type Required Description
user path string true User ID, name, or me
organization path string(uuid) true Organization ID

Example responses

200 Response

{
  "budget": 0,
  "credits_consumed": 0
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.WorkspaceQuota

To perform this operation, you must be authenticated. Learn more.

Get groups by organization (paginated)

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/paginated-groups \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/paginated-groups

Unlike "Get groups by organization" (GET /organizations/{organization}/groups), which authorizes each group individually via its ACL, this endpoint requires organization-wide group read permission and does no per-group filtering. It is therefore not a drop-in replacement: callers without org-wide group read receive an error rather than a filtered subset.

The q parameter uses the shared filter syntax. Bare terms (including multi-word) perform a free-text search over group name and display name. search: is the only accepted key and unknown keys return 400. Because group display names may contain colons, a value with a colon must be quoted, e.g. search:"team: frontend"; an unquoted colon fails with Query element "team:" cannot start or end with ':'.

This endpoint returns group summaries without the member roster: each group carries only total_member_count and no members field. Callers that need the roster use the group members endpoint (GET /groups/{group}/members).

Parameters

Name In Type Required Description
organization path string true Organization ID or name
q query string false Search query (see description for syntax and colon-quoting)
limit query integer false Page limit
offset query integer false Page offset
after_id query string(uuid) false After ID

Example responses

200 Response

{
  "count": 0,
  "groups": [
    {
      "avatar_url": "http://example.com",
      "display_name": "string",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "name": "string",
      "organization_display_name": "string",
      "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
      "organization_name": "string",
      "quota_allowance": 0,
      "source": "user",
      "total_member_count": 0
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.PaginatedGroupsResponse

To perform this operation, you must be authenticated. Learn more.

Serve provisioner daemon

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/provisionerdaemons/serve \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/provisionerdaemons/serve

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID

Responses

Status Meaning Description Schema
101 Switching Protocols Switching Protocols

To perform this operation, you must be authenticated. Learn more.

List provisioner key

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/provisionerkeys \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/provisionerkeys

Parameters

Name In Type Required Description
organization path string true Organization ID

Example responses

200 Response

[
  {
    "created_at": "2019-08-24T14:15:22Z",
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "name": "string",
    "organization": "452c1a86-a0af-475b-b03f-724878b0f387",
    "tags": {
      "property1": "string",
      "property2": "string"
    }
  }
]

Responses

Status Meaning Description Schema
200 OK OK array of codersdk.ProvisionerKey

Response Schema

Status Code 200

Name Type Required Restrictions Description
[array item] array false
» created_at string(date-time) false
» id string(uuid) false
» name string false
» organization string(uuid) false
» tags codersdk.ProvisionerKeyTags false
»» [any property] string false

To perform this operation, you must be authenticated. Learn more.

Create provisioner key

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/organizations/{organization}/provisionerkeys \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

POST /api/v2/organizations/{organization}/provisionerkeys

Parameters

Name In Type Required Description
organization path string true Organization ID

Example responses

201 Response

{
  "key": "string"
}

Responses

Status Meaning Description Schema
201 Created Created codersdk.CreateProvisionerKeyResponse

To perform this operation, you must be authenticated. Learn more.

List provisioner key daemons

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/provisionerkeys/daemons \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/provisionerkeys/daemons

Parameters

Name In Type Required Description
organization path string true Organization ID

Example responses

200 Response

[
  {
    "daemons": [
      {
        "api_version": "string",
        "created_at": "2019-08-24T14:15:22Z",
        "current_job": {
          "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
          "status": "pending",
          "template_display_name": "string",
          "template_icon": "string",
          "template_name": "string"
        },
        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        "key_id": "1e779c8a-6786-4c89-b7c3-a6666f5fd6b5",
        "key_name": "string",
        "last_seen_at": "2019-08-24T14:15:22Z",
        "name": "string",
        "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
        "previous_job": {
          "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
          "status": "pending",
          "template_display_name": "string",
          "template_icon": "string",
          "template_name": "string"
        },
        "provisioners": [
          "string"
        ],
        "status": "offline",
        "tags": {
          "property1": "string",
          "property2": "string"
        },
        "version": "string"
      }
    ],
    "key": {
      "created_at": "2019-08-24T14:15:22Z",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "name": "string",
      "organization": "452c1a86-a0af-475b-b03f-724878b0f387",
      "tags": {
        "property1": "string",
        "property2": "string"
      }
    }
  }
]

Responses

Status Meaning Description Schema
200 OK OK array of codersdk.ProvisionerKeyDaemons

Response Schema

Status Code 200

Name Type Required Restrictions Description
[array item] array false
» daemons array false
»» api_version string false
»» created_at string(date-time) false
»» current_job codersdk.ProvisionerDaemonJob false
»»» id string(uuid) false
»»» status codersdk.ProvisionerJobStatus false
»»» template_display_name string false
»»» template_icon string false
»»» template_name string false
»» id string(uuid) false
»» key_id string(uuid) false
»» key_name string false Optional fields.
»» last_seen_at string(date-time) false
»» name string false
»» organization_id string(uuid) false
»» previous_job codersdk.ProvisionerDaemonJob false
»» provisioners array false
»» status codersdk.ProvisionerDaemonStatus false
»» tags object false
»»» [any property] string false
»» version string false
» key codersdk.ProvisionerKey false
»» created_at string(date-time) false
»» id string(uuid) false
»» name string false
»» organization string(uuid) false
»» tags codersdk.ProvisionerKeyTags false
»»» [any property] string false

Enumerated Values

Property Value(s)
status busy, canceled, canceling, failed, idle, offline, pending, running, succeeded

To perform this operation, you must be authenticated. Learn more.

Delete provisioner key

Code samples

# Example request using curl
curl -X DELETE http://coder-server:8080/api/v2/organizations/{organization}/provisionerkeys/{provisionerkey} \
  -H 'Coder-Session-Token: API_KEY'

DELETE /api/v2/organizations/{organization}/provisionerkeys/{provisionerkey}

Parameters

Name In Type Required Description
organization path string true Organization ID
provisionerkey path string true Provisioner key name

Responses

Status Meaning Description Schema
204 No Content No Content

To perform this operation, you must be authenticated. Learn more.

Get the available organization idp sync claim fields

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/settings/idpsync/available-fields \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/settings/idpsync/available-fields

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID

Example responses

200 Response

[
  "string"
]

Responses

Status Meaning Description Schema
200 OK OK array of string

Response Schema

To perform this operation, you must be authenticated. Learn more.

Get the organization idp sync claim field values

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/settings/idpsync/field-values?claimField=string \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/settings/idpsync/field-values

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID
claimField query string(string) true Claim Field

Example responses

200 Response

[
  "string"
]

Responses

Status Meaning Description Schema
200 OK OK array of string

Response Schema

To perform this operation, you must be authenticated. Learn more.

Get group IdP Sync settings by organization

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/settings/idpsync/groups \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/settings/idpsync/groups

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID

Example responses

200 Response

{
  "auto_create_missing_groups": true,
  "field": "string",
  "legacy_group_name_mapping": {
    "property1": "string",
    "property2": "string"
  },
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  },
  "regex_filter": {}
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.GroupSyncSettings

To perform this operation, you must be authenticated. Learn more.

Update group IdP Sync settings by organization

Code samples

# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/organizations/{organization}/settings/idpsync/groups \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PATCH /api/v2/organizations/{organization}/settings/idpsync/groups

Body parameter

{
  "auto_create_missing_groups": true,
  "field": "string",
  "legacy_group_name_mapping": {
    "property1": "string",
    "property2": "string"
  },
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  },
  "regex_filter": {}
}

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID
body body codersdk.GroupSyncSettings true New settings

Example responses

200 Response

{
  "auto_create_missing_groups": true,
  "field": "string",
  "legacy_group_name_mapping": {
    "property1": "string",
    "property2": "string"
  },
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  },
  "regex_filter": {}
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.GroupSyncSettings

To perform this operation, you must be authenticated. Learn more.

Update group IdP Sync config

Code samples

# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/organizations/{organization}/settings/idpsync/groups/config \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PATCH /api/v2/organizations/{organization}/settings/idpsync/groups/config

Body parameter

{
  "auto_create_missing_groups": true,
  "field": "string",
  "regex_filter": {}
}

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID or name
body body codersdk.PatchGroupIDPSyncConfigRequest true New config values

Example responses

200 Response

{
  "auto_create_missing_groups": true,
  "field": "string",
  "legacy_group_name_mapping": {
    "property1": "string",
    "property2": "string"
  },
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  },
  "regex_filter": {}
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.GroupSyncSettings

To perform this operation, you must be authenticated. Learn more.

Update group IdP Sync mapping

Code samples

# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/organizations/{organization}/settings/idpsync/groups/mapping \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PATCH /api/v2/organizations/{organization}/settings/idpsync/groups/mapping

Body parameter

{
  "add": [
    {
      "gets": "string",
      "given": "string"
    }
  ],
  "remove": [
    {
      "gets": "string",
      "given": "string"
    }
  ]
}

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID or name
body body codersdk.PatchGroupIDPSyncMappingRequest true Description of the mappings to add and remove

Example responses

200 Response

{
  "auto_create_missing_groups": true,
  "field": "string",
  "legacy_group_name_mapping": {
    "property1": "string",
    "property2": "string"
  },
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  },
  "regex_filter": {}
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.GroupSyncSettings

To perform this operation, you must be authenticated. Learn more.

Get role IdP Sync settings by organization

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/settings/idpsync/roles \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/settings/idpsync/roles

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID

Example responses

200 Response

{
  "field": "string",
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  }
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.RoleSyncSettings

To perform this operation, you must be authenticated. Learn more.

Update role IdP Sync settings by organization

Code samples

# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/organizations/{organization}/settings/idpsync/roles \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PATCH /api/v2/organizations/{organization}/settings/idpsync/roles

Body parameter

{
  "field": "string",
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  }
}

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID
body body codersdk.RoleSyncSettings true New settings

Example responses

200 Response

{
  "field": "string",
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  }
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.RoleSyncSettings

To perform this operation, you must be authenticated. Learn more.

Update role IdP Sync config

Code samples

# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/organizations/{organization}/settings/idpsync/roles/config \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PATCH /api/v2/organizations/{organization}/settings/idpsync/roles/config

Body parameter

{
  "field": "string"
}

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID or name
body body codersdk.PatchRoleIDPSyncConfigRequest true New config values

Example responses

200 Response

{
  "field": "string",
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  }
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.RoleSyncSettings

To perform this operation, you must be authenticated. Learn more.

Update role IdP Sync mapping

Code samples

# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/organizations/{organization}/settings/idpsync/roles/mapping \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PATCH /api/v2/organizations/{organization}/settings/idpsync/roles/mapping

Body parameter

{
  "add": [
    {
      "gets": "string",
      "given": "string"
    }
  ],
  "remove": [
    {
      "gets": "string",
      "given": "string"
    }
  ]
}

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID or name
body body codersdk.PatchRoleIDPSyncMappingRequest true Description of the mappings to add and remove

Example responses

200 Response

{
  "field": "string",
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  }
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.RoleSyncSettings

To perform this operation, you must be authenticated. Learn more.

Get workspace sharing settings for organization

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/organizations/{organization}/settings/workspace-sharing \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/organizations/{organization}/settings/workspace-sharing

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID

Example responses

200 Response

{
  "shareable_workspace_owners": "none",
  "sharing_disabled": true,
  "sharing_globally_disabled": true
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.WorkspaceSharingSettings

To perform this operation, you must be authenticated. Learn more.

Update workspace sharing settings for organization

Code samples

# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/organizations/{organization}/settings/workspace-sharing \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PATCH /api/v2/organizations/{organization}/settings/workspace-sharing

Body parameter

{
  "shareable_workspace_owners": "none",
  "sharing_disabled": true
}

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID
body body codersdk.UpdateWorkspaceSharingSettingsRequest true Workspace sharing settings

Example responses

200 Response

{
  "shareable_workspace_owners": "none",
  "sharing_disabled": true,
  "sharing_globally_disabled": true
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.WorkspaceSharingSettings

To perform this operation, you must be authenticated. Learn more.

Fetch provisioner key details

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/provisionerkeys/{provisionerkey} \
  -H 'Accept: application/json'

GET /api/v2/provisionerkeys/{provisionerkey}

Parameters

Name In Type Required Description
provisionerkey path string true Provisioner Key

Example responses

200 Response

{
  "created_at": "2019-08-24T14:15:22Z",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "name": "string",
  "organization": "452c1a86-a0af-475b-b03f-724878b0f387",
  "tags": {
    "property1": "string",
    "property2": "string"
  }
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.ProvisionerKey

To perform this operation, you must be authenticated. Learn more.

Get active replicas

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/replicas \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/replicas

Example responses

200 Response

[
  {
    "created_at": "2019-08-24T14:15:22Z",
    "database_latency": 0,
    "error": "string",
    "hostname": "string",
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "region_id": 0,
    "relay_address": "string"
  }
]

Responses

Status Meaning Description Schema
200 OK OK array of codersdk.Replica

Response Schema

Status Code 200

Name Type Required Restrictions Description
[array item] array false
» created_at string(date-time) false Created at is the timestamp when the replica was first seen.
» database_latency integer false Database latency is the latency in microseconds to the database.
» error string false Error is the replica error.
» hostname string false Hostname is the hostname of the replica.
» id string(uuid) false ID is the unique identifier for the replica.
» region_id integer false Region ID is the region of the replica.
» relay_address string false Relay address is the accessible address to relay DERP connections.

To perform this operation, you must be authenticated. Learn more.

Get the available idp sync claim fields

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/settings/idpsync/available-fields \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/settings/idpsync/available-fields

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID

Example responses

200 Response

[
  "string"
]

Responses

Status Meaning Description Schema
200 OK OK array of string

Response Schema

To perform this operation, you must be authenticated. Learn more.

Get the idp sync claim field values

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/settings/idpsync/field-values?claimField=string \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/settings/idpsync/field-values

Parameters

Name In Type Required Description
organization path string(uuid) true Organization ID
claimField query string(string) true Claim Field

Example responses

200 Response

[
  "string"
]

Responses

Status Meaning Description Schema
200 OK OK array of string

Response Schema

To perform this operation, you must be authenticated. Learn more.

Get organization IdP Sync settings

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/settings/idpsync/organization \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/settings/idpsync/organization

Example responses

200 Response

{
  "field": "string",
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  },
  "organization_assign_default": true
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.OrganizationSyncSettings

To perform this operation, you must be authenticated. Learn more.

Update organization IdP Sync settings

Code samples

# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/settings/idpsync/organization \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PATCH /api/v2/settings/idpsync/organization

Body parameter

{
  "field": "string",
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  },
  "organization_assign_default": true
}

Parameters

Name In Type Required Description
body body codersdk.OrganizationSyncSettings true New settings

Example responses

200 Response

{
  "field": "string",
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  },
  "organization_assign_default": true
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.OrganizationSyncSettings

To perform this operation, you must be authenticated. Learn more.

Update organization IdP Sync config

Code samples

# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/settings/idpsync/organization/config \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PATCH /api/v2/settings/idpsync/organization/config

Body parameter

{
  "assign_default": true,
  "field": "string"
}

Parameters

Name In Type Required Description
body body codersdk.PatchOrganizationIDPSyncConfigRequest true New config values

Example responses

200 Response

{
  "field": "string",
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  },
  "organization_assign_default": true
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.OrganizationSyncSettings

To perform this operation, you must be authenticated. Learn more.

Update organization IdP Sync mapping

Code samples

# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/settings/idpsync/organization/mapping \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PATCH /api/v2/settings/idpsync/organization/mapping

Body parameter

{
  "add": [
    {
      "gets": "string",
      "given": "string"
    }
  ],
  "remove": [
    {
      "gets": "string",
      "given": "string"
    }
  ]
}

Parameters

Name In Type Required Description
body body codersdk.PatchOrganizationIDPSyncMappingRequest true Description of the mappings to add and remove

Example responses

200 Response

{
  "field": "string",
  "mapping": {
    "property1": [
      "string"
    ],
    "property2": [
      "string"
    ]
  },
  "organization_assign_default": true
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.OrganizationSyncSettings

To perform this operation, you must be authenticated. Learn more.

Get template ACLs

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/templates/{template}/acl \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/templates/{template}/acl

Parameters

Name In Type Required Description
template path string(uuid) true Template ID

Example responses

200 Response

{
  "group": [
    {
      "avatar_url": "http://example.com",
      "display_name": "string",
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "members": [
        {
          "avatar_url": "http://example.com",
          "created_at": "2019-08-24T14:15:22Z",
          "email": "user@example.com",
          "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
          "is_service_account": true,
          "last_seen_at": "2019-08-24T14:15:22Z",
          "login_type": "",
          "name": "string",
          "status": "active",
          "theme_preference": "string",
          "updated_at": "2019-08-24T14:15:22Z",
          "username": "string"
        }
      ],
      "name": "string",
      "organization_display_name": "string",
      "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
      "organization_name": "string",
      "quota_allowance": 0,
      "role": "admin",
      "source": "user",
      "total_member_count": 0
    }
  ],
  "users": [
    {
      "avatar_url": "http://example.com",
      "created_at": "2019-08-24T14:15:22Z",
      "email": "user@example.com",
      "has_ai_seat": true,
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "is_service_account": true,
      "last_seen_at": "2019-08-24T14:15:22Z",
      "login_type": "",
      "name": "string",
      "organization_ids": [
        "497f6eca-6276-4993-bfeb-53cbbbba6f08"
      ],
      "role": "admin",
      "roles": [
        {
          "display_name": "string",
          "name": "string",
          "organization_id": "string"
        }
      ],
      "status": "active",
      "theme_preference": "string",
      "updated_at": "2019-08-24T14:15:22Z",
      "username": "string"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.TemplateACL

To perform this operation, you must be authenticated. Learn more.

Update template ACL

Code samples

# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/templates/{template}/acl \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PATCH /api/v2/templates/{template}/acl

Body parameter

{
  "group_perms": {
    "8bd26b20-f3e8-48be-a903-46bb920cf671": "use",
    "<group_id>": "admin"
  },
  "user_perms": {
    "4df59e74-c027-470b-ab4d-cbba8963a5e9": "use",
    "<user_id>": "admin"
  }
}

Parameters

Name In Type Required Description
template path string(uuid) true Template ID
body body codersdk.UpdateTemplateACL true Update template ACL request

Example responses

200 Response

{
  "detail": "string",
  "message": "string",
  "validations": [
    {
      "detail": "string",
      "field": "string"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.Response

To perform this operation, you must be authenticated. Learn more.

Get template available acl users/groups

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/templates/{template}/acl/available \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/templates/{template}/acl/available

Parameters

Name In Type Required Description
template path string(uuid) true Template ID

Example responses

200 Response

[
  {
    "groups": [
      {
        "avatar_url": "http://example.com",
        "display_name": "string",
        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        "members": [
          {
            "avatar_url": "http://example.com",
            "created_at": "2019-08-24T14:15:22Z",
            "email": "user@example.com",
            "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
            "is_service_account": true,
            "last_seen_at": "2019-08-24T14:15:22Z",
            "login_type": "",
            "name": "string",
            "status": "active",
            "theme_preference": "string",
            "updated_at": "2019-08-24T14:15:22Z",
            "username": "string"
          }
        ],
        "name": "string",
        "organization_display_name": "string",
        "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6",
        "organization_name": "string",
        "quota_allowance": 0,
        "source": "user",
        "total_member_count": 0
      }
    ],
    "users": [
      {
        "avatar_url": "http://example.com",
        "created_at": "2019-08-24T14:15:22Z",
        "email": "user@example.com",
        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        "is_service_account": true,
        "last_seen_at": "2019-08-24T14:15:22Z",
        "login_type": "",
        "name": "string",
        "status": "active",
        "theme_preference": "string",
        "updated_at": "2019-08-24T14:15:22Z",
        "username": "string"
      }
    ]
  }
]

Responses

Status Meaning Description Schema
200 OK OK array of codersdk.ACLAvailable

Response Schema

Status Code 200

Name Type Required Restrictions Description
[array item] array false
» groups array false
»» avatar_url string(uri) false
»» display_name string false
»» id string(uuid) false
»» members array false
»»» avatar_url string(uri) false
»»» created_at string(date-time) true
»»» email string(email) true
»»» id string(uuid) true
»»» is_service_account boolean false
»»» last_seen_at string(date-time) false
»»» login_type codersdk.LoginType false
»»» name string false
»»» status codersdk.UserStatus false
»»» theme_preference string false Deprecated: this value should be retrieved from codersdk.UserPreferenceSettings instead.
»»» updated_at string(date-time) false
»»» username string true
»» name string false
»» organization_display_name string false
»» organization_id string(uuid) false
»» organization_name string false
»» quota_allowance integer false
»» source codersdk.GroupSource false
»» total_member_count integer false How many members are in this group. Shows the total count, even if the user is not authorized to read group member details. May be greater than len(Group.Members).
» users array false

Enumerated Values

Property Value(s)
login_type ``, github, none, oidc, password, token
status active, suspended
source oidc, user

To perform this operation, you must be authenticated. Learn more.

Invalidate presets for template

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/templates/{template}/prebuilds/invalidate \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

POST /api/v2/templates/{template}/prebuilds/invalidate

Parameters

Name In Type Required Description
template path string(uuid) true Template ID

Example responses

200 Response

{
  "invalidated": [
    {
      "preset_name": "string",
      "template_name": "string",
      "template_version_name": "string"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.InvalidatePresetsResponse

To perform this operation, you must be authenticated. Learn more.

Get user AI budget override

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/ai/budget/override \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/users/{user}/ai/budget/override

Parameters

Name In Type Required Description
user path string true User ID, username, or me

Example responses

200 Response

{
  "created_at": "2019-08-24T14:15:22Z",
  "group_id": "306db4e0-7449-4501-b76f-075576fe2d8f",
  "spend_limit_micros": 0,
  "updated_at": "2019-08-24T14:15:22Z",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.UserAIBudgetOverride

To perform this operation, you must be authenticated. Learn more.

Upsert user AI budget override

Code samples

# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/users/{user}/ai/budget/override \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PUT /api/v2/users/{user}/ai/budget/override

Body parameter

{
  "group_id": "306db4e0-7449-4501-b76f-075576fe2d8f",
  "spend_limit_micros": 0
}

Parameters

Name In Type Required Description
user path string true User ID, username, or me
body body codersdk.UpsertUserAIBudgetOverrideRequest true Upsert user AI budget override request

Example responses

200 Response

{
  "created_at": "2019-08-24T14:15:22Z",
  "group_id": "306db4e0-7449-4501-b76f-075576fe2d8f",
  "spend_limit_micros": 0,
  "updated_at": "2019-08-24T14:15:22Z",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.UserAIBudgetOverride

To perform this operation, you must be authenticated. Learn more.

Delete user AI budget override

Code samples

# Example request using curl
curl -X DELETE http://coder-server:8080/api/v2/users/{user}/ai/budget/override \
  -H 'Coder-Session-Token: API_KEY'

DELETE /api/v2/users/{user}/ai/budget/override

Parameters

Name In Type Required Description
user path string true User ID, username, or me

Responses

Status Meaning Description Schema
204 No Content No Content

To perform this operation, you must be authenticated. Learn more.

Get user AI spend

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/ai/spend \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/users/{user}/ai/spend

Parameters

Name In Type Required Description
user path string true User ID, username, or me

Example responses

200 Response

{
  "current_spend_micros": 0,
  "effective_budget": {
    "limit_source": "user_override",
    "spend_limit_micros": 0
  },
  "effective_group_id": "85e2b926-ddfb-4c66-b68e-b66e5acec6c0",
  "period_end": "2019-08-24T14:15:22Z",
  "period_start": "2019-08-24T14:15:22Z",
  "user_id": "a169451c-8525-4352-b8ca-070dd449a1a5"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.UserAISpendStatus

To perform this operation, you must be authenticated. Learn more.

Get user quiet hours schedule

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/users/{user}/quiet-hours \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/users/{user}/quiet-hours

Parameters

Name In Type Required Description
user path string(uuid) true User ID

Example responses

200 Response

[
  {
    "next": "2019-08-24T14:15:22Z",
    "raw_schedule": "string",
    "time": "string",
    "timezone": "string",
    "user_can_set": true,
    "user_set": true
  }
]

Responses

Status Meaning Description Schema
200 OK OK array of codersdk.UserQuietHoursScheduleResponse

Response Schema

Status Code 200

Name Type Required Restrictions Description
[array item] array false
» next string(date-time) false Next is the next time that the quiet hours window will start.
» raw_schedule string false
» time string false Time is the time of day that the quiet hours window starts in the given Timezone each day.
» timezone string false raw format from the cron expression, UTC if unspecified
» user_can_set boolean false User can set is true if the user is allowed to set their own quiet hours schedule. If false, the user cannot set a custom schedule and the default schedule will always be used.
» user_set boolean false User set is true if the user has set their own quiet hours schedule. If false, the user is using the default schedule.

To perform this operation, you must be authenticated. Learn more.

Update user quiet hours schedule

Code samples

# Example request using curl
curl -X PUT http://coder-server:8080/api/v2/users/{user}/quiet-hours \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PUT /api/v2/users/{user}/quiet-hours

Body parameter

{
  "schedule": "string"
}

Parameters

Name In Type Required Description
user path string(uuid) true User ID
body body codersdk.UpdateUserQuietHoursScheduleRequest true Update schedule request

Example responses

200 Response

[
  {
    "next": "2019-08-24T14:15:22Z",
    "raw_schedule": "string",
    "time": "string",
    "timezone": "string",
    "user_can_set": true,
    "user_set": true
  }
]

Responses

Status Meaning Description Schema
200 OK OK array of codersdk.UserQuietHoursScheduleResponse

Response Schema

Status Code 200

Name Type Required Restrictions Description
[array item] array false
» next string(date-time) false Next is the next time that the quiet hours window will start.
» raw_schedule string false
» time string false Time is the time of day that the quiet hours window starts in the given Timezone each day.
» timezone string false raw format from the cron expression, UTC if unspecified
» user_can_set boolean false User can set is true if the user is allowed to set their own quiet hours schedule. If false, the user cannot set a custom schedule and the default schedule will always be used.
» user_set boolean false User set is true if the user has set their own quiet hours schedule. If false, the user is using the default schedule.

To perform this operation, you must be authenticated. Learn more.

Get workspace quota by user deprecated

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/workspace-quota/{user} \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/workspace-quota/{user}

Parameters

Name In Type Required Description
user path string true User ID, name, or me

Example responses

200 Response

{
  "budget": 0,
  "credits_consumed": 0
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.WorkspaceQuota

To perform this operation, you must be authenticated. Learn more.

Get workspace proxies

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/workspaceproxies \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/workspaceproxies

Example responses

200 Response

[
  {
    "regions": [
      {
        "created_at": "2019-08-24T14:15:22Z",
        "deleted": true,
        "derp_enabled": true,
        "derp_only": true,
        "display_name": "string",
        "healthy": true,
        "icon_url": "string",
        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        "name": "string",
        "path_app_url": "string",
        "status": {
          "checked_at": "2019-08-24T14:15:22Z",
          "report": {
            "errors": [
              "string"
            ],
            "warnings": [
              "string"
            ]
          },
          "status": "ok"
        },
        "updated_at": "2019-08-24T14:15:22Z",
        "version": "string",
        "wildcard_hostname": "string"
      }
    ]
  }
]

Responses

Status Meaning Description Schema
200 OK OK array of codersdk.RegionsResponse-codersdk_WorkspaceProxy

Response Schema

Status Code 200

Name Type Required Restrictions Description
[array item] array false
» regions array false
»» created_at string(date-time) false
»» deleted boolean false
»» derp_enabled boolean false
»» derp_only boolean false
»» display_name string false
»» healthy boolean false
»» icon_url string false
»» id string(uuid) false
»» name string false
»» path_app_url string false Path app URL is the URL to the base path for path apps. Optional unless wildcard_hostname is set. E.g. https://us.example.com
»» status codersdk.WorkspaceProxyStatus false Status is the latest status check of the proxy. This will be empty for deleted proxies. This value can be used to determine if a workspace proxy is healthy and ready to use.
»»» checked_at string(date-time) false
»»» report codersdk.ProxyHealthReport false Report provides more information about the health of the workspace proxy.
»»»» errors array false Errors are problems that prevent the workspace proxy from being healthy
»»»» warnings array false Warnings do not prevent the workspace proxy from being healthy, but should be addressed.
»»» status codersdk.ProxyHealthStatus false
»» updated_at string(date-time) false
»» version string false
»» wildcard_hostname string false Wildcard hostname is the wildcard hostname for subdomain apps. E.g. .us.example.com E.g.--suffix.au.example.com Optional. Does not need to be on the same domain as PathAppURL.

Enumerated Values

Property Value(s)
status ok, unhealthy, unreachable, unregistered

To perform this operation, you must be authenticated. Learn more.

Create workspace proxy

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/api/v2/workspaceproxies \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

POST /api/v2/workspaceproxies

Body parameter

{
  "display_name": "string",
  "icon": "string",
  "name": "string"
}

Parameters

Name In Type Required Description
body body codersdk.CreateWorkspaceProxyRequest true Create workspace proxy request

Example responses

201 Response

{
  "created_at": "2019-08-24T14:15:22Z",
  "deleted": true,
  "derp_enabled": true,
  "derp_only": true,
  "display_name": "string",
  "healthy": true,
  "icon_url": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "name": "string",
  "path_app_url": "string",
  "status": {
    "checked_at": "2019-08-24T14:15:22Z",
    "report": {
      "errors": [
        "string"
      ],
      "warnings": [
        "string"
      ]
    },
    "status": "ok"
  },
  "updated_at": "2019-08-24T14:15:22Z",
  "version": "string",
  "wildcard_hostname": "string"
}

Responses

Status Meaning Description Schema
201 Created Created codersdk.WorkspaceProxy

To perform this operation, you must be authenticated. Learn more.

Get workspace proxy

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/workspaceproxies/{workspaceproxy} \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/workspaceproxies/{workspaceproxy}

Parameters

Name In Type Required Description
workspaceproxy path string(uuid) true Proxy ID or name

Example responses

200 Response

{
  "created_at": "2019-08-24T14:15:22Z",
  "deleted": true,
  "derp_enabled": true,
  "derp_only": true,
  "display_name": "string",
  "healthy": true,
  "icon_url": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "name": "string",
  "path_app_url": "string",
  "status": {
    "checked_at": "2019-08-24T14:15:22Z",
    "report": {
      "errors": [
        "string"
      ],
      "warnings": [
        "string"
      ]
    },
    "status": "ok"
  },
  "updated_at": "2019-08-24T14:15:22Z",
  "version": "string",
  "wildcard_hostname": "string"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.WorkspaceProxy

To perform this operation, you must be authenticated. Learn more.

Delete workspace proxy

Code samples

# Example request using curl
curl -X DELETE http://coder-server:8080/api/v2/workspaceproxies/{workspaceproxy} \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

DELETE /api/v2/workspaceproxies/{workspaceproxy}

Parameters

Name In Type Required Description
workspaceproxy path string(uuid) true Proxy ID or name

Example responses

200 Response

{
  "detail": "string",
  "message": "string",
  "validations": [
    {
      "detail": "string",
      "field": "string"
    }
  ]
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.Response

To perform this operation, you must be authenticated. Learn more.

Update workspace proxy

Code samples

# Example request using curl
curl -X PATCH http://coder-server:8080/api/v2/workspaceproxies/{workspaceproxy} \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

PATCH /api/v2/workspaceproxies/{workspaceproxy}

Body parameter

{
  "display_name": "string",
  "icon": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "name": "string",
  "regenerate_token": true
}

Parameters

Name In Type Required Description
workspaceproxy path string(uuid) true Proxy ID or name
body body codersdk.PatchWorkspaceProxy true Update workspace proxy request

Example responses

200 Response

{
  "created_at": "2019-08-24T14:15:22Z",
  "deleted": true,
  "derp_enabled": true,
  "derp_only": true,
  "display_name": "string",
  "healthy": true,
  "icon_url": "string",
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "name": "string",
  "path_app_url": "string",
  "status": {
    "checked_at": "2019-08-24T14:15:22Z",
    "report": {
      "errors": [
        "string"
      ],
      "warnings": [
        "string"
      ]
    },
    "status": "ok"
  },
  "updated_at": "2019-08-24T14:15:22Z",
  "version": "string",
  "wildcard_hostname": "string"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.WorkspaceProxy

To perform this operation, you must be authenticated. Learn more.

Get workspace external agent credentials

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/api/v2/workspaces/{workspace}/external-agent/{agent}/credentials \
  -H 'Accept: application/json' \
  -H 'Coder-Session-Token: API_KEY'

GET /api/v2/workspaces/{workspace}/external-agent/{agent}/credentials

Parameters

Name In Type Required Description
workspace path string(uuid) true Workspace ID
agent path string true Agent name

Example responses

200 Response

{
  "agent_token": "string",
  "command": "string"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.ExternalAgentCredentials

To perform this operation, you must be authenticated. Learn more.

OAuth2 authorization request (GET - show authorization page)

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/oauth2/authorize?client_id=string&state=string&response_type=code \
  -H 'Coder-Session-Token: API_KEY'

GET /oauth2/authorize

Parameters

Name In Type Required Description
client_id query string true Client ID
state query string true A random unguessable string
response_type query string true Response type
redirect_uri query string false Redirect here after authorization
scope query string false Space-separated scopes to request. Each must be supported by this deployment, and the app's allowlist, when it has one, must cover the permissions requested rather than name each scope. Defaults to that allowlist, or to coder:all for an app with no allowlist

Enumerated Values

Parameter Value(s)
response_type code, token

Responses

Status Meaning Description Schema
200 OK Returns HTML authorization page

To perform this operation, you must be authenticated. Learn more.

OAuth2 authorization request (POST - process authorization)

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/oauth2/authorize?client_id=string&state=string&response_type=code \
  -H 'Coder-Session-Token: API_KEY'

POST /oauth2/authorize

Parameters

Name In Type Required Description
client_id query string true Client ID
state query string true A random unguessable string
response_type query string true Response type
redirect_uri query string false Redirect here after authorization
scope query string false Space-separated scopes to request. Each must be supported by this deployment, and the app's allowlist, when it has one, must cover the permissions requested rather than name each scope. Defaults to that allowlist, or to coder:all for an app with no allowlist

Enumerated Values

Parameter Value(s)
response_type code, token

Responses

Status Meaning Description Schema
302 Found Returns redirect with authorization code

To perform this operation, you must be authenticated. Learn more.

Get OAuth2 client configuration (RFC 7592)

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/oauth2/clients/{client_id} \
  -H 'Accept: application/json'

GET /oauth2/clients/{client_id}

Parameters

Name In Type Required Description
client_id path string true Client ID

Example responses

200 Response

{
  "client_id": "string",
  "client_id_issued_at": 0,
  "client_name": "string",
  "client_secret_expires_at": 0,
  "client_uri": "string",
  "contacts": [
    "string"
  ],
  "grant_types": [
    "authorization_code"
  ],
  "jwks": {},
  "jwks_uri": "string",
  "logo_uri": "string",
  "policy_uri": "string",
  "redirect_uris": [
    "string"
  ],
  "registration_access_token": "string",
  "registration_client_uri": "string",
  "response_types": [
    "code"
  ],
  "scope": "string",
  "software_id": "string",
  "software_version": "string",
  "token_endpoint_auth_method": "client_secret_basic",
  "tos_uri": "string"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.OAuth2ClientConfiguration

Update OAuth2 client configuration (RFC 7592)

Code samples

# Example request using curl
curl -X PUT http://coder-server:8080/oauth2/clients/{client_id} \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json'

PUT /oauth2/clients/{client_id}

Body parameter

{
  "client_name": "string",
  "client_uri": "string",
  "contacts": [
    "string"
  ],
  "grant_types": [
    "authorization_code"
  ],
  "jwks": {},
  "jwks_uri": "string",
  "logo_uri": "string",
  "policy_uri": "string",
  "redirect_uris": [
    "string"
  ],
  "response_types": [
    "code"
  ],
  "scope": "string",
  "software_id": "string",
  "software_statement": "string",
  "software_version": "string",
  "token_endpoint_auth_method": "client_secret_basic",
  "tos_uri": "string"
}

Parameters

Name In Type Required Description
client_id path string true Client ID
body body codersdk.OAuth2ClientRegistrationRequest true Client update request

Example responses

200 Response

{
  "client_id": "string",
  "client_id_issued_at": 0,
  "client_name": "string",
  "client_secret_expires_at": 0,
  "client_uri": "string",
  "contacts": [
    "string"
  ],
  "grant_types": [
    "authorization_code"
  ],
  "jwks": {},
  "jwks_uri": "string",
  "logo_uri": "string",
  "policy_uri": "string",
  "redirect_uris": [
    "string"
  ],
  "registration_access_token": "string",
  "registration_client_uri": "string",
  "response_types": [
    "code"
  ],
  "scope": "string",
  "software_id": "string",
  "software_version": "string",
  "token_endpoint_auth_method": "client_secret_basic",
  "tos_uri": "string"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.OAuth2ClientConfiguration

Delete OAuth2 client registration (RFC 7592)

Code samples

# Example request using curl
curl -X DELETE http://coder-server:8080/oauth2/clients/{client_id}

DELETE /oauth2/clients/{client_id}

Parameters

Name In Type Required Description
client_id path string true Client ID

Responses

Status Meaning Description Schema
204 No Content No Content

OAuth2 dynamic client registration (RFC 7591)

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/oauth2/register \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json'

POST /oauth2/register

Body parameter

{
  "client_name": "string",
  "client_uri": "string",
  "contacts": [
    "string"
  ],
  "grant_types": [
    "authorization_code"
  ],
  "jwks": {},
  "jwks_uri": "string",
  "logo_uri": "string",
  "policy_uri": "string",
  "redirect_uris": [
    "string"
  ],
  "response_types": [
    "code"
  ],
  "scope": "string",
  "software_id": "string",
  "software_statement": "string",
  "software_version": "string",
  "token_endpoint_auth_method": "client_secret_basic",
  "tos_uri": "string"
}

Parameters

Name In Type Required Description
body body codersdk.OAuth2ClientRegistrationRequest true Client registration request

Example responses

201 Response

{
  "client_id": "string",
  "client_id_issued_at": 0,
  "client_name": "string",
  "client_secret": "string",
  "client_secret_expires_at": 0,
  "client_uri": "string",
  "contacts": [
    "string"
  ],
  "grant_types": [
    "authorization_code"
  ],
  "jwks": {},
  "jwks_uri": "string",
  "logo_uri": "string",
  "policy_uri": "string",
  "redirect_uris": [
    "string"
  ],
  "registration_access_token": "string",
  "registration_client_uri": "string",
  "response_types": [
    "code"
  ],
  "scope": "string",
  "software_id": "string",
  "software_version": "string",
  "token_endpoint_auth_method": "client_secret_basic",
  "tos_uri": "string"
}

Responses

Status Meaning Description Schema
201 Created Created codersdk.OAuth2ClientRegistrationResponse

Revoke OAuth2 tokens (RFC 7009)

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/oauth2/revoke \

POST /oauth2/revoke

Body parameter

client_id: string
token: string
token_type_hint: string

Parameters

Name In Type Required Description
body body object true
» client_id body string true Client ID for authentication
» token body string true The token to revoke
» token_type_hint body string false Hint about token type (access_token or refresh_token)

Responses

Status Meaning Description Schema
200 OK Token successfully revoked

OAuth2 token exchange

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/oauth2/tokens \
  -H 'Accept: application/json'

POST /oauth2/tokens

Body parameter

client_id: string
client_secret: string
code: string
code_verifier: string
refresh_token: string
grant_type: authorization_code

Parameters

Name In Type Required Description
body body object false
» client_id body string false Client ID, required if grant_type=authorization_code
» client_secret body string false Client secret, required if grant_type=authorization_code and the client is confidential. Public clients (token_endpoint_auth_method=none) send no secret.
» code body string false Authorization code, required if grant_type=authorization_code
» code_verifier body string false PKCE code verifier, required if grant_type=authorization_code. 43-128 characters per RFC 7636.
» refresh_token body string false Refresh token, required if grant_type=refresh_token
» grant_type body string true Grant type

Enumerated Values

Parameter Value(s)
» grant_type authorization_code, client_credentials, implicit, password, refresh_token

Example responses

200 Response

{
  "access_token": "string",
  "expires_in": 0,
  "expiry": "string",
  "refresh_token": "string",
  "token_type": "string"
}

Responses

Status Meaning Description Schema
200 OK OK oauth2.Token

Delete OAuth2 application tokens

Code samples

# Example request using curl
curl -X DELETE http://coder-server:8080/oauth2/tokens?client_id=string \
  -H 'Coder-Session-Token: API_KEY'

DELETE /oauth2/tokens

Parameters

Name In Type Required Description
client_id query string true Client ID

Responses

Status Meaning Description Schema
204 No Content No Content

To perform this operation, you must be authenticated. Learn more.

SCIM 2.0: Service Provider Config

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/scim/v2/ServiceProviderConfig

GET /scim/v2/ServiceProviderConfig

Responses

Status Meaning Description Schema
200 OK OK

SCIM 2.0: Get users

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/scim/v2/Users \
  -H 'Authorization: API_KEY'

GET /scim/v2/Users

Responses

Status Meaning Description Schema
200 OK OK

To perform this operation, you must be authenticated. Learn more.

SCIM 2.0: Create new user

Code samples

# Example request using curl
curl -X POST http://coder-server:8080/scim/v2/Users \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: API_KEY'

POST /scim/v2/Users

Body parameter

{
  "active": true,
  "emails": [
    {
      "display": "string",
      "primary": true,
      "type": "string",
      "value": "user@example.com"
    }
  ],
  "groups": [
    null
  ],
  "id": "string",
  "meta": {
    "resourceType": "string"
  },
  "name": {
    "familyName": "string",
    "givenName": "string"
  },
  "schemas": [
    "string"
  ],
  "userName": "string"
}

Parameters

Name In Type Required Description
body body legacyscim.SCIMUser true New user

Example responses

200 Response

{
  "active": true,
  "emails": [
    {
      "display": "string",
      "primary": true,
      "type": "string",
      "value": "user@example.com"
    }
  ],
  "groups": [
    null
  ],
  "id": "string",
  "meta": {
    "resourceType": "string"
  },
  "name": {
    "familyName": "string",
    "givenName": "string"
  },
  "schemas": [
    "string"
  ],
  "userName": "string"
}

Responses

Status Meaning Description Schema
200 OK OK legacyscim.SCIMUser

To perform this operation, you must be authenticated. Learn more.

SCIM 2.0: Get user by ID

Code samples

# Example request using curl
curl -X GET http://coder-server:8080/scim/v2/Users/{id} \
  -H 'Authorization: API_KEY'

GET /scim/v2/Users/{id}

Parameters

Name In Type Required Description
id path string(uuid) true User ID

Responses

Status Meaning Description Schema
404 Not Found Not Found

To perform this operation, you must be authenticated. Learn more.

SCIM 2.0: Replace user account

Code samples

# Example request using curl
curl -X PUT http://coder-server:8080/scim/v2/Users/{id} \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/scim+json' \
  -H 'Authorization: API_KEY'

PUT /scim/v2/Users/{id}

Body parameter

{
  "active": true,
  "emails": [
    {
      "display": "string",
      "primary": true,
      "type": "string",
      "value": "user@example.com"
    }
  ],
  "groups": [
    null
  ],
  "id": "string",
  "meta": {
    "resourceType": "string"
  },
  "name": {
    "familyName": "string",
    "givenName": "string"
  },
  "schemas": [
    "string"
  ],
  "userName": "string"
}

Parameters

Name In Type Required Description
id path string(uuid) true User ID
body body legacyscim.SCIMUser true Replace user request

Example responses

200 Response

{
  "avatar_url": "http://example.com",
  "created_at": "2019-08-24T14:15:22Z",
  "email": "user@example.com",
  "has_ai_seat": true,
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "is_service_account": true,
  "last_seen_at": "2019-08-24T14:15:22Z",
  "login_type": "",
  "name": "string",
  "organization_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "roles": [
    {
      "display_name": "string",
      "name": "string",
      "organization_id": "string"
    }
  ],
  "status": "active",
  "theme_preference": "string",
  "updated_at": "2019-08-24T14:15:22Z",
  "username": "string"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.User

To perform this operation, you must be authenticated. Learn more.

SCIM 2.0: Update user account

Code samples

# Example request using curl
curl -X PATCH http://coder-server:8080/scim/v2/Users/{id} \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/scim+json' \
  -H 'Authorization: API_KEY'

PATCH /scim/v2/Users/{id}

Body parameter

{
  "active": true,
  "emails": [
    {
      "display": "string",
      "primary": true,
      "type": "string",
      "value": "user@example.com"
    }
  ],
  "groups": [
    null
  ],
  "id": "string",
  "meta": {
    "resourceType": "string"
  },
  "name": {
    "familyName": "string",
    "givenName": "string"
  },
  "schemas": [
    "string"
  ],
  "userName": "string"
}

Parameters

Name In Type Required Description
id path string(uuid) true User ID
body body legacyscim.SCIMUser true Update user request

Example responses

200 Response

{
  "avatar_url": "http://example.com",
  "created_at": "2019-08-24T14:15:22Z",
  "email": "user@example.com",
  "has_ai_seat": true,
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "is_service_account": true,
  "last_seen_at": "2019-08-24T14:15:22Z",
  "login_type": "",
  "name": "string",
  "organization_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "roles": [
    {
      "display_name": "string",
      "name": "string",
      "organization_id": "string"
    }
  ],
  "status": "active",
  "theme_preference": "string",
  "updated_at": "2019-08-24T14:15:22Z",
  "username": "string"
}

Responses

Status Meaning Description Schema
200 OK OK codersdk.User

To perform this operation, you must be authenticated. Learn more.