apitokens
Package github.com/emergent-company/emergent.memory/apps/server/pkg/sdk/apitokens
The apitokens client manages project-scoped API tokens (emt_* prefix). Tokens are used to authenticate SDK clients with Mode: "apitoken" or Mode: "apikey".
Methods
Section titled “Methods”func (c *Client) Create(ctx context.Context, projectID string, req *CreateTokenRequest) (*CreateTokenResponse, error)func (c *Client) List(ctx context.Context, projectID string) (*ListResponse, error)func (c *Client) Get(ctx context.Context, projectID, tokenID string) (*APIToken, error)func (c *Client) Revoke(ctx context.Context, projectID, tokenID string) errorKey Types
Section titled “Key Types”APIToken
Section titled “APIToken”type APIToken struct { ID string Name string ProjectID string Prefix string // First few chars of the token (for identification) ExpiresAt *time.Time LastUsedAt *time.Time CreatedAt time.Time}CreateTokenResponse
Section titled “CreateTokenResponse”type CreateTokenResponse struct { Token string // Full token value — only returned on creation APIToken}CreateTokenRequest
Section titled “CreateTokenRequest”type CreateTokenRequest struct { Name string ExpiresAt *time.Time // nil for no expiration}ListResponse
Section titled “ListResponse”type ListResponse struct { Tokens []APIToken}Example
Section titled “Example”// Create a tokenresp, err := client.APITokens.Create(ctx, "proj_xyz", &apitokens.CreateTokenRequest{ Name: "CI/CD pipeline token",})if err != nil { return err}// Save resp.Token — it won't be shown againfmt.Printf("Created token prefix: %s\n", resp.Prefix)
// List tokenslist, err := client.APITokens.List(ctx, "proj_xyz")for _, tok := range list.Tokens { fmt.Printf("%s — %s\n", tok.Name, tok.Prefix)}
// Revoke a tokenerr = client.APITokens.Revoke(ctx, "proj_xyz", "tok_abc123")