Skip to content

Validate current API key

client.Auth.Validate(ctx) (*AuthValidateResponse, error)
GET/v1/auth/validate

Returns metadata for the current API key, including the subject type and granted public scopes. Use this endpoint to confirm a key is active before making scoped API requests.

Required scope: None

Rate limit category: Read

ReturnsExpand Collapse
type AuthValidateResponse struct{…}
Active bool

Whether the current API key is valid. Always true on successful responses.

Scopes []string

Granted public scopes for the current API key. Empty when the key has full access.

SubjectType AuthValidateResponseSubjectType

Whether the API key belongs to a user or workspace.

One of the following:
const AuthValidateResponseSubjectTypeUser AuthValidateResponseSubjectType = "user"
const AuthValidateResponseSubjectTypeWorkspace AuthValidateResponseSubjectType = "workspace"
TokenType AuthValidateResponseTokenType

Credential family, always api_key.

Validate current API key

package main

import (
  "context"
  "fmt"

  "github.com/Lightfld/lightfield-go"
  "github.com/Lightfld/lightfield-go/option"
)

func main() {
  client := githubcomlightfldlightfieldgo.NewClient(
    option.WithAPIKey("My API Key"),
  )
  authValidateResponse, err := client.Auth.Validate(context.TODO())
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", authValidateResponse.Active)
}
{
  "active": true,
  "scopes": [
    "string"
  ],
  "subjectType": "user",
  "tokenType": "api_key"
}
Returns Examples
{
  "active": true,
  "scopes": [
    "string"
  ],
  "subjectType": "user",
  "tokenType": "api_key"
}