# Workspace Admin ## List all workspaces in the account `client.WorkspaceAdmin.List(ctx, query) (*CursorPagination[Workspace], error)` **get** `/v1/account/workspaces` Lists every workspace in the account, optionally including archived ones. Admin only. ### Parameters - `query WorkspaceAdminListParams` - `Cursor param.Field[string]` Pagination cursor from previous response - `IncludeArchived param.Field[bool]` When true, archived workspaces are included in the results. Defaults to false (active workspaces only). - `Limit param.Field[int64]` Maximum number of results to return ### Returns - `type Workspace struct{…}` - `Metadata AccountResourceMetadata` AccountResourceMetadata is used to represent a resource that is associated to an account but not to a workspace. - `ID string` Unique identifier for the resource (prefixed ULID, e.g., "apikey_01HXK...") - `AccountID string` Account this resource belongs to for multi-tenant isolation (prefixed ULID) - `Name string` Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool") Required for resources that users interact with directly - `ProfileID string` - `ExternalID string` External ID for the resource (e.g., a workflow ID from an external system) - `Labels map[string, string]` Arbitrary key-value pairs for categorization and filtering Examples: {"environment": "production", "team": "platform", "version": "v2"} - `Spec WorkspaceSpec` - `Description string` - `Status WorkspaceStatus` Lifecycle status of the workspace. Archived workspaces reject all requests scoped to them. Server-populated. - `const WorkspaceStatusStatusEnabled WorkspaceStatus = "STATUS_ENABLED"` - `const WorkspaceStatusStatusDisabled WorkspaceStatus = "STATUS_DISABLED"` - `const WorkspaceStatusStatusArchived WorkspaceStatus = "STATUS_ARCHIVED"` ### Example ```go package main import ( "context" "fmt" "github.com/cadenya/cadenya-go" "github.com/cadenya/cadenya-go/option" ) func main() { client := cadenya.NewClient( option.WithAPIKey("My API Key"), ) page, err := client.WorkspaceAdmin.List(context.TODO(), cadenya.WorkspaceAdminListParams{ }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "items": [ { "metadata": { "id": "id", "accountId": "accountId", "name": "name", "profileId": "profileId", "externalId": "externalId", "labels": { "foo": "string" } }, "spec": { "description": "description" }, "status": "STATUS_ENABLED" } ], "pagination": { "nextCursor": "nextCursor", "total": 0 } } ``` ## Create a workspace `client.WorkspaceAdmin.New(ctx, body) (*Workspace, error)` **post** `/v1/account/workspaces` Creates a new workspace in the account. Admin only. ### Parameters - `body WorkspaceAdminNewParams` - `Metadata param.Field[WorkspaceAdminNewParamsMetadata]` CreateAccountResourceMetadata contains the user-provided fields for creating an account-scoped resource. Read-only fields (id, account_id, profile_id) are excluded since they are set by the server. - `Name string` Human-readable name for the resource (e.g., "Production API Key", "Staging Workspace") - `ExternalID string` External ID for the resource (e.g., a workflow ID from an external system) - `Labels map[string, string]` Arbitrary key-value pairs for categorization and filtering Examples: {"environment": "production", "team": "platform", "version": "v2"} - `Spec param.Field[WorkspaceSpec]` ### Returns - `type Workspace struct{…}` - `Metadata AccountResourceMetadata` AccountResourceMetadata is used to represent a resource that is associated to an account but not to a workspace. - `ID string` Unique identifier for the resource (prefixed ULID, e.g., "apikey_01HXK...") - `AccountID string` Account this resource belongs to for multi-tenant isolation (prefixed ULID) - `Name string` Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool") Required for resources that users interact with directly - `ProfileID string` - `ExternalID string` External ID for the resource (e.g., a workflow ID from an external system) - `Labels map[string, string]` Arbitrary key-value pairs for categorization and filtering Examples: {"environment": "production", "team": "platform", "version": "v2"} - `Spec WorkspaceSpec` - `Description string` - `Status WorkspaceStatus` Lifecycle status of the workspace. Archived workspaces reject all requests scoped to them. Server-populated. - `const WorkspaceStatusStatusEnabled WorkspaceStatus = "STATUS_ENABLED"` - `const WorkspaceStatusStatusDisabled WorkspaceStatus = "STATUS_DISABLED"` - `const WorkspaceStatusStatusArchived WorkspaceStatus = "STATUS_ARCHIVED"` ### Example ```go package main import ( "context" "fmt" "github.com/cadenya/cadenya-go" "github.com/cadenya/cadenya-go/option" ) func main() { client := cadenya.NewClient( option.WithAPIKey("My API Key"), ) workspace, err := client.WorkspaceAdmin.New(context.TODO(), cadenya.WorkspaceAdminNewParams{ Metadata: cadenya.F(cadenya.WorkspaceAdminNewParamsMetadata{ Name: cadenya.F("name"), }), Spec: cadenya.F(cadenya.WorkspaceSpecParam{ }), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", workspace.Metadata) } ``` #### Response ```json { "metadata": { "id": "id", "accountId": "accountId", "name": "name", "profileId": "profileId", "externalId": "externalId", "labels": { "foo": "string" } }, "spec": { "description": "description" }, "status": "STATUS_ENABLED" } ``` ## Get a workspace by ID `client.WorkspaceAdmin.Get(ctx, workspaceID) (*Workspace, error)` **get** `/v1/account/workspaces/{workspaceId}` Retrieves a workspace in the account by ID. Admin only. ### Parameters - `workspaceID string` ### Returns - `type Workspace struct{…}` - `Metadata AccountResourceMetadata` AccountResourceMetadata is used to represent a resource that is associated to an account but not to a workspace. - `ID string` Unique identifier for the resource (prefixed ULID, e.g., "apikey_01HXK...") - `AccountID string` Account this resource belongs to for multi-tenant isolation (prefixed ULID) - `Name string` Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool") Required for resources that users interact with directly - `ProfileID string` - `ExternalID string` External ID for the resource (e.g., a workflow ID from an external system) - `Labels map[string, string]` Arbitrary key-value pairs for categorization and filtering Examples: {"environment": "production", "team": "platform", "version": "v2"} - `Spec WorkspaceSpec` - `Description string` - `Status WorkspaceStatus` Lifecycle status of the workspace. Archived workspaces reject all requests scoped to them. Server-populated. - `const WorkspaceStatusStatusEnabled WorkspaceStatus = "STATUS_ENABLED"` - `const WorkspaceStatusStatusDisabled WorkspaceStatus = "STATUS_DISABLED"` - `const WorkspaceStatusStatusArchived WorkspaceStatus = "STATUS_ARCHIVED"` ### Example ```go package main import ( "context" "fmt" "github.com/cadenya/cadenya-go" "github.com/cadenya/cadenya-go/option" ) func main() { client := cadenya.NewClient( option.WithAPIKey("My API Key"), ) workspace, err := client.WorkspaceAdmin.Get(context.TODO(), "workspaceId") if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", workspace.Metadata) } ``` #### Response ```json { "metadata": { "id": "id", "accountId": "accountId", "name": "name", "profileId": "profileId", "externalId": "externalId", "labels": { "foo": "string" } }, "spec": { "description": "description" }, "status": "STATUS_ENABLED" } ``` ## Update a workspace `client.WorkspaceAdmin.Update(ctx, workspaceID, body) (*Workspace, error)` **patch** `/v1/account/workspaces/{workspaceId}` Updates a workspace's metadata (e.g. name) and spec. Admin only. ### Parameters - `workspaceID string` - `body WorkspaceAdminUpdateParams` - `Metadata param.Field[WorkspaceAdminUpdateParamsMetadata]` UpdateAccountResourceMetadata contains the user-provided fields for updating an account-scoped resource. Read-only fields (id, account_id, profile_id) are excluded since they are set by the server. - `Name string` Human-readable name for the resource (e.g., "Production API Key", "Staging Workspace") - `ExternalID string` External ID for the resource (e.g., a workflow ID from an external system) - `Labels map[string, string]` Arbitrary key-value pairs for categorization and filtering Examples: {"environment": "production", "team": "platform", "version": "v2"} - `Spec param.Field[WorkspaceSpec]` - `UpdateMask param.Field[string]` Fields to update. ### Returns - `type Workspace struct{…}` - `Metadata AccountResourceMetadata` AccountResourceMetadata is used to represent a resource that is associated to an account but not to a workspace. - `ID string` Unique identifier for the resource (prefixed ULID, e.g., "apikey_01HXK...") - `AccountID string` Account this resource belongs to for multi-tenant isolation (prefixed ULID) - `Name string` Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool") Required for resources that users interact with directly - `ProfileID string` - `ExternalID string` External ID for the resource (e.g., a workflow ID from an external system) - `Labels map[string, string]` Arbitrary key-value pairs for categorization and filtering Examples: {"environment": "production", "team": "platform", "version": "v2"} - `Spec WorkspaceSpec` - `Description string` - `Status WorkspaceStatus` Lifecycle status of the workspace. Archived workspaces reject all requests scoped to them. Server-populated. - `const WorkspaceStatusStatusEnabled WorkspaceStatus = "STATUS_ENABLED"` - `const WorkspaceStatusStatusDisabled WorkspaceStatus = "STATUS_DISABLED"` - `const WorkspaceStatusStatusArchived WorkspaceStatus = "STATUS_ARCHIVED"` ### Example ```go package main import ( "context" "fmt" "github.com/cadenya/cadenya-go" "github.com/cadenya/cadenya-go/option" ) func main() { client := cadenya.NewClient( option.WithAPIKey("My API Key"), ) workspace, err := client.WorkspaceAdmin.Update( context.TODO(), "workspaceId", cadenya.WorkspaceAdminUpdateParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", workspace.Metadata) } ``` #### Response ```json { "metadata": { "id": "id", "accountId": "accountId", "name": "name", "profileId": "profileId", "externalId": "externalId", "labels": { "foo": "string" } }, "spec": { "description": "description" }, "status": "STATUS_ENABLED" } ``` ## Archive a workspace `client.WorkspaceAdmin.Archive(ctx, workspaceID) error` **delete** `/v1/account/workspaces/{workspaceId}` Archives a workspace (soft delete). The workspace is retained, but any subsequent request scoped to it returns a permission error. Archiving the account's last active (non-archived) workspace is not allowed and returns FailedPrecondition. Admin only. ### Parameters - `workspaceID string` ### Example ```go package main import ( "context" "github.com/cadenya/cadenya-go" "github.com/cadenya/cadenya-go/option" ) func main() { client := cadenya.NewClient( option.WithAPIKey("My API Key"), ) err := client.WorkspaceAdmin.Archive(context.TODO(), "workspaceId") if err != nil { panic(err.Error()) } } ``` ## Domain Types ### Workspace Member - `type WorkspaceMember struct{…}` A member of a workspace: the profile granted access plus the actor row that links it to the workspace. Returned by member list/add operations. - `ActorID string` The actor row linking the profile to the workspace (the junction record). - `ProfileID string` The account profile that has access to the workspace. - `AddedAt Time` When the member was added to the workspace. - `Email string` Email address of the member's profile. - `Name string` Display name of the member's profile. # Members ## List workspace members `client.WorkspaceAdmin.Members.List(ctx, workspaceID, query) (*CursorPagination[WorkspaceMember], error)` **get** `/v1/account/workspaces/{workspaceId}/members` Lists the members of a workspace. Admin only. ### Parameters - `workspaceID string` - `query WorkspaceAdminMemberListParams` - `Cursor param.Field[string]` Pagination cursor from previous response - `Limit param.Field[int64]` Maximum number of results to return ### Returns - `type WorkspaceMember struct{…}` A member of a workspace: the profile granted access plus the actor row that links it to the workspace. Returned by member list/add operations. - `ActorID string` The actor row linking the profile to the workspace (the junction record). - `ProfileID string` The account profile that has access to the workspace. - `AddedAt Time` When the member was added to the workspace. - `Email string` Email address of the member's profile. - `Name string` Display name of the member's profile. ### Example ```go package main import ( "context" "fmt" "github.com/cadenya/cadenya-go" "github.com/cadenya/cadenya-go/option" ) func main() { client := cadenya.NewClient( option.WithAPIKey("My API Key"), ) page, err := client.WorkspaceAdmin.Members.List( context.TODO(), "workspaceId", cadenya.WorkspaceAdminMemberListParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "items": [ { "actorId": "actorId", "profileId": "profileId", "addedAt": "2019-12-27T18:11:19.117Z", "email": "email", "name": "name" } ], "pagination": { "nextCursor": "nextCursor", "total": 0 } } ``` ## Add a member to a workspace `client.WorkspaceAdmin.Members.Add(ctx, workspaceID, body) (*WorkspaceMember, error)` **post** `/v1/account/workspaces/{workspaceId}/members` Grants a profile access to the workspace by creating (or reactivating) the actor that links the profile to the workspace. Accepts either an existing profile_id or an email to resolve-or-invite. Idempotent for an already-active member. Admin only. ### Parameters - `workspaceID string` - `body WorkspaceAdminMemberAddParams` - `Email param.Field[string]` Email address to add (resolve-or-invite). Mutually exclusive with profile_id. - `ProfileID param.Field[string]` An existing account profile to add. Mutually exclusive with email. ### Returns - `type WorkspaceMember struct{…}` A member of a workspace: the profile granted access plus the actor row that links it to the workspace. Returned by member list/add operations. - `ActorID string` The actor row linking the profile to the workspace (the junction record). - `ProfileID string` The account profile that has access to the workspace. - `AddedAt Time` When the member was added to the workspace. - `Email string` Email address of the member's profile. - `Name string` Display name of the member's profile. ### Example ```go package main import ( "context" "fmt" "github.com/cadenya/cadenya-go" "github.com/cadenya/cadenya-go/option" ) func main() { client := cadenya.NewClient( option.WithAPIKey("My API Key"), ) workspaceMember, err := client.WorkspaceAdmin.Members.Add( context.TODO(), "workspaceId", cadenya.WorkspaceAdminMemberAddParams{ }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", workspaceMember.ActorID) } ``` #### Response ```json { "actorId": "actorId", "profileId": "profileId", "addedAt": "2019-12-27T18:11:19.117Z", "email": "email", "name": "name" } ``` ## Remove a member from a workspace `client.WorkspaceAdmin.Members.Remove(ctx, workspaceID, profileID) error` **delete** `/v1/account/workspaces/{workspaceId}/members/{profileId}` Revokes a member's access by deactivating their actor; the member is immediately cut off. The underlying profile is not deleted. Admin only. ### Parameters - `workspaceID string` - `profileID string` ### Example ```go package main import ( "context" "github.com/cadenya/cadenya-go" "github.com/cadenya/cadenya-go/option" ) func main() { client := cadenya.NewClient( option.WithAPIKey("My API Key"), ) err := client.WorkspaceAdmin.Members.Remove( context.TODO(), "workspaceId", "profileId", ) if err != nil { panic(err.Error()) } } ``` # Profiles ## Search account profiles `client.WorkspaceAdmin.Profiles.List(ctx, query) (*CursorPagination[Profile], error)` **get** `/v1/account/profiles` Searches the account's profiles for a member picker, with free-form name/email search and an optional type filter. Account-scoped; admin only. ### Parameters - `query WorkspaceAdminProfileListParams` - `Cursor param.Field[string]` Pagination cursor from previous response - `Limit param.Field[int64]` Maximum number of results to return - `Query param.Field[string]` Free-form search over profile name and email. Case-insensitive substring match; empty returns all profiles. ### Returns - `type Profile struct{…}` A profile identifies a user or non-human principal (such as an API key) at the account level. Profiles are account-scoped and can be granted access to multiple workspaces. - `Metadata AccountResourceMetadata` AccountResourceMetadata is used to represent a resource that is associated to an account but not to a workspace. - `ID string` Unique identifier for the resource (prefixed ULID, e.g., "apikey_01HXK...") - `AccountID string` Account this resource belongs to for multi-tenant isolation (prefixed ULID) - `Name string` Human-readable name for the resource (e.g., "Customer Support Agent", "Email Tool") Required for resources that users interact with directly - `ProfileID string` - `ExternalID string` External ID for the resource (e.g., a workflow ID from an external system) - `Labels map[string, string]` Arbitrary key-value pairs for categorization and filtering Examples: {"environment": "production", "team": "platform", "version": "v2"} - `Spec ProfileSpec` Configuration for a profile. - `Type ProfileSpecType` Whether this profile represents a human user, an API key, or a system principal. - `const ProfileSpecTypeProfileTypeUnspecified ProfileSpecType = "PROFILE_TYPE_UNSPECIFIED"` - `const ProfileSpecTypeProfileTypeUser ProfileSpecType = "PROFILE_TYPE_USER"` - `const ProfileSpecTypeProfileTypeAPIKey ProfileSpecType = "PROFILE_TYPE_API_KEY"` - `const ProfileSpecTypeProfileTypeSystem ProfileSpecType = "PROFILE_TYPE_SYSTEM"` - `Email string` Email address of the profile. Required and unique within an account for user profiles. - `Name string` Display name (e.g., "Bobby Tables"). ### Example ```go package main import ( "context" "fmt" "github.com/cadenya/cadenya-go" "github.com/cadenya/cadenya-go/option" ) func main() { client := cadenya.NewClient( option.WithAPIKey("My API Key"), ) page, err := client.WorkspaceAdmin.Profiles.List(context.TODO(), cadenya.WorkspaceAdminProfileListParams{ }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "items": [ { "metadata": { "id": "id", "accountId": "accountId", "name": "name", "profileId": "profileId", "externalId": "externalId", "labels": { "foo": "string" } }, "spec": { "type": "PROFILE_TYPE_UNSPECIFIED", "email": "email", "name": "name" } } ], "pagination": { "nextCursor": "nextCursor", "total": 0 } } ```