Check authorization
POST
CoderSessionTokenheader
Coder-Session-Token<token>Authorization request
application/json- body
checks?Checks is a map keyed with an arbitrary string to a permission check. The key can be any string that is helpful to the caller, and allows multiple permission checks to be run in a single request. The key ensures that each permission check has the same key in the response.
OK
application/json- response
[key: string]?booleanThe samples read CODER_URL and CODER_SESSION_TOKEN: set up your environment.
curl -X POST \ "$CODER_URL/api/v2/authcheck" \ -H "Coder-Session-Token: $CODER_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "checks": { "property1": { "action": "create", "object": { "any_org": true, "organization_id": "string", "owner_id": "string", "resource_id": "string", "resource_type": "*" } }, "property2": { "action": "create", "object": { "any_org": true, "organization_id": "string", "owner_id": "string", "resource_id": "string", "resource_type": "*" } } }}'const { CODER_URL, CODER_SESSION_TOKEN } = process.env;const url = `${CODER_URL}/api/v2/authcheck`;const response = await fetch(url, { method: "POST", headers: { "Coder-Session-Token": CODER_SESSION_TOKEN, "Content-Type": "application/json", }, body: JSON.stringify({ checks: { property1: { action: "create", object: { any_org: true, organization_id: "string", owner_id: "string", resource_id: "string", resource_type: "*", }, }, property2: { action: "create", object: { any_org: true, organization_id: "string", owner_id: "string", resource_id: "string", resource_type: "*", }, }, }, }),});console.log(response.status, await response.text());import osimport requestsurl = os.environ["CODER_URL"] + "/api/v2/authcheck"token = os.environ["CODER_SESSION_TOKEN"]response = requests.post( url, headers={ "Coder-Session-Token": token, }, json={ "checks": { "property1": { "action": "create", "object": { "any_org": True, "organization_id": "string", "owner_id": "string", "resource_id": "string", "resource_type": "*", }, }, "property2": { "action": "create", "object": { "any_org": True, "organization_id": "string", "owner_id": "string", "resource_id": "string", "resource_type": "*", }, }, }, },)print(response.status_code, response.text)package mainimport ( "fmt" "io" "net/http" "os" "strings")func main() { body := strings.NewReader(`{ "checks": { "property1": { "action": "create", "object": { "any_org": true, "organization_id": "string", "owner_id": "string", "resource_id": "string", "resource_type": "*" } }, "property2": { "action": "create", "object": { "any_org": true, "organization_id": "string", "owner_id": "string", "resource_id": "string", "resource_type": "*" } } }}`) url := os.Getenv("CODER_URL") + "/api/v2/authcheck" token := os.Getenv("CODER_SESSION_TOKEN") req, err := http.NewRequest(http.MethodPost, url, body) if err != nil { panic(err) } req.Header.Set("Coder-Session-Token", token) req.Header.Set("Content-Type", "application/json") resp, err := http.DefaultClient.Do(req) if err != nil { panic(err) } defer resp.Body.Close() out, err := io.ReadAll(resp.Body) if err != nil { panic(err) } fmt.Println(resp.Status, string(out))}Example Response200
{ "property1": true, "property2": true}