Skip to content
Scalekit Docs
Talk to an Engineer Dashboard

Resource

Manage resource clients and the consents your end users grant against them

Use scalekitClient.Resources() to manage resource clients and to read and revoke the consents your end users grant against one. A consent records that one end user allowed a specific resource client to act on their behalf.

The same audit and revoke actions are available in the dashboard under Managing MCP clients.

clientResourceshttps://github.com/scalekit-inc/scalekit-sdk-go/blob/main/resource.go
#asyncGetResource

Retrieves a single resource by id.

paramctxcontext.Context

Request context

paramresourceIdstring

The resource to fetch (format: res_...).

returns*GetResourceResponse

Resource object.

resource, err := scalekitClient.Resources().GetResource(ctx, "res_xxx")
if err != nil {
// handle error
}
fmt.Println(resource.Resource)
clientResourceshttps://github.com/scalekit-inc/scalekit-sdk-go/blob/main/resource.go
#asyncListResources

Lists resources of a given type in the environment, with pagination.

paramctxcontext.Context

Request context

paramresourceTypescalekit.ResourceType

The resource type to filter by. Supported value: scalekit.ResourceTypeMcpServer.

paramoptionsscalekit.ListResourcesOptions

Optional fields: PageSize (max 30), PageToken.

PageSize, PageToken
returns*ListResourcesResponse

Paginated resources.

resources, err := scalekitClient.Resources().ListResources(ctx, scalekit.ResourceTypeMcpServer, scalekit.ListResourcesOptions{
PageSize: 20,
})
if err != nil {
// handle error
}
for _, r := range resources.Resources {
fmt.Println(r.Id, r.Scopes)
}
clientResourceshttps://github.com/scalekit-inc/scalekit-sdk-go/blob/main/resource.go
#asyncCreateResourceClient

Creates a resource client. Returns the created Client and a PlainSecret - the plaintext client secret, only available at creation time.

paramctxcontext.Context

Request context

paramresourceIdstring

The resource to create the client for (format: res_...).

paramclient*clients.ResourceClient

The client properties. Scopes should be the same or a subset of the scopes available for the resource. CustomClaims is a flat key/value structure only. Expiry (access token lifetime in seconds) defaults to the resource’s configured expiry. RedirectUris are the allowed redirect URIs for a pre-registered client. There is no Audience field - audience is always server-determined.

Name, Description, Scopes, CustomClaims, Expiry, RedirectUris
returns*CreateResourceClientResponse

The created client and its plaintext secret.

import (
clients "github.com/scalekit-inc/scalekit-sdk-go/v2/pkg/grpc/scalekit/v1/clients"
)
resource, err := scalekitClient.Resources().GetResource(ctx, "res_xxx")
if err != nil {
// handle error
}
var allowedScopes []string
for _, s := range resource.Resource.Scopes {
if s.Enabled {
allowedScopes = append(allowedScopes, s.Name)
}
}
created, err := scalekitClient.Resources().CreateResourceClient(ctx, "res_xxx", &clients.ResourceClient{
Name: "My Resource Client",
Scopes: allowedScopes,
})
if err != nil {
// handle error
}
fmt.Println(created.Client.ClientId)
// Store created.PlainSecret in your secret manager now - it is never returned again.
// It grants full access as this client, so if it leaks, replace it right away:
// create a new secret and delete the compromised one (delete first if you're
// already at your secret limit; if it's your only secret, raise the limit
// before rotating).
clientResourceshttps://github.com/scalekit-inc/scalekit-sdk-go/blob/main/resource.go
#asyncGetResourceClient

Fetches a single resource client, along with the end-users who have granted it consent.

paramctxcontext.Context

Request context

paramresourceIdstring

The resource the client must belong to (format: res_...).

paramclientIdstring

The client ID (format: m2m_...).

returns*GetResourceClientResponse

The resource client.

got, err := scalekitClient.Resources().GetResourceClient(ctx, "res_xxx", "m2m_xxx")
if err != nil {
// handle error
}
fmt.Println(got.Client.Name)
clientResourceshttps://github.com/scalekit-inc/scalekit-sdk-go/blob/main/resource.go
#asyncListResourceClients

Lists resource clients.

paramctxcontext.Context

Request context

paramresourceIdstring

The resource whose clients to list (format: res_...).

returns*ListResourceClientsResponse

The resource’s clients, plus TotalDcrClients and TotalStaticClients counts.

list, err := scalekitClient.Resources().ListResourceClients(ctx, "res_xxx")
if err != nil {
// handle error
}
fmt.Println(list.TotalDcrClients, list.TotalStaticClients)
for _, c := range list.Clients {
fmt.Println(c.ClientId, c.Name)
}
clientResourceshttps://github.com/scalekit-inc/scalekit-sdk-go/blob/main/resource.go
#asyncUpdateResourceClient

Updates a resource client.

paramctxcontext.Context

Request context

paramresourceIdstring

The resource the client must belong to (format: res_...).

paramclientIdstring

The client ID to update (format: m2m_...).

paramoptionsscalekit.UpdateResourceClientOptions

Pointer fields - only the ones set (non-nil) are changed. Name/Description are a no-op server-side when set to an empty string, not a clear. Scopes, CustomClaims, and RedirectUris replace their existing values; set an empty (non-nil) slice to clear one of them. There’s no Audience field.

Name, Description, Scopes, CustomClaims, Expiry, RedirectUris
returns*UpdateResourceClientResponse

The updated client.

resource, err := scalekitClient.Resources().GetResource(ctx, "res_xxx")
if err != nil {
// handle error
}
var allowedScopes []string
for _, s := range resource.Resource.Scopes {
if s.Enabled {
allowedScopes = append(allowedScopes, s.Name)
}
}
newName := "Updated Name"
updated, err := scalekitClient.Resources().UpdateResourceClient(ctx, "res_xxx", "m2m_xxx", scalekit.UpdateResourceClientOptions{
Name: &newName,
Scopes: &allowedScopes,
})
if err != nil {
// handle error
}
fmt.Println(updated.Client.Name, updated.Client.Scopes)
clientResourceshttps://github.com/scalekit-inc/scalekit-sdk-go/blob/main/resource.go
#asyncDeleteResourceClient

Deletes resource clients. Returns an error if the client is missing or scoped to a different resource.

paramctxcontext.Context

Request context

paramresourceIdstring

The resource the client must belong to (format: res_...).

paramclientIdstring

The client ID to delete (format: m2m_...).

returnserror

nil on success.

if err := scalekitClient.Resources().DeleteResourceClient(ctx, "res_xxx", "m2m_xxx"); err != nil {
// handle error
}
clientResourceshttps://github.com/scalekit-inc/scalekit-sdk-go/blob/main/resource.go
#asyncCreateResourceClientSecret

Creates a new secret for a resource client. Only 2 client secrets are recommended to exist at a given point in time - use DeleteResourceClientSecret to remove an existing one first if you need more.

The plaintext client secret is only ever returned here, at creation time.

paramctxcontext.Context

Request context

paramresourceIdstring

The resource the client must belong to (format: res_...).

paramclientIdstring

The client ID to create a secret for (format: m2m_...).

returns*CreateClientSecretResponse

The new secret, including its plaintext value.

secret, err := scalekitClient.Resources().CreateResourceClientSecret(ctx, "res_xxx", "m2m_xxx")
if err != nil {
// handle error
}
// Store secret.PlainSecret in your secret manager now - it is never returned again.
// It grants full access as this client, so if it leaks, replace it right away:
// create a new secret and delete the compromised one (delete first if you're
// already at your secret limit; if it's your only secret, raise the limit
// before rotating).
clientResourceshttps://github.com/scalekit-inc/scalekit-sdk-go/blob/main/resource.go
#asyncDeleteResourceClientSecret

Permanently deletes a secret from a resource client. A client must always keep at least 1 secret - calling this on a client’s last remaining secret fails.

paramctxcontext.Context

Request context

paramresourceIdstring

The resource the client must belong to (format: res_...).

paramclientIdstring

The client ID the secret belongs to (format: m2m_...).

paramsecretIdstring

The secret ID to delete (format: sks_...).

returnserror

nil on success.

if err := scalekitClient.Resources().DeleteResourceClientSecret(ctx, "res_xxx", "m2m_xxx", "sks_xxx"); err != nil {
// handle error
}
clientResourceshttps://github.com/scalekit-inc/scalekit-sdk-go/blob/main/resource.go
#asyncListUserConsents

Lists the end-user consents granted against a resource, with pagination. Use this to audit who authorized a client, and to find the ConsentId you need before revoking.

Filter by user in one of two ways. Pass UserIds to match external user IDs exactly and case-sensitively. Pass Search for a case-insensitive substring match. When you give both, UserIds wins and Search is ignored.

paramctxcontext.Context

Request context

paramresourceIdstring

The resource whose consents to list (format: res_...).

paramoptionsscalekit.ListUserConsentsOptions

Optional fields: Search, PageSize (max 30), PageToken, UserIds (max 25, takes precedence over Search).

Search, PageSize, PageToken, UserIds
returns*ListResourceUserConsentsResponse

Consents with Id, ExternalUserId, ClientId, ClientName, Scopes, and GrantedAt, plus TotalSize and the NextPageToken / PrevPageToken cursors.

consents, err := scalekitClient.Resources().ListUserConsents(ctx, "res_xxx", scalekit.ListUserConsentsOptions{
PageSize: 20,
UserIds: []string{"user_456"}, // optional; takes precedence over Search
})
if err != nil {
// handle error
}
fmt.Println(consents.TotalSize, consents.NextPageToken)
for _, c := range consents.Consents {
fmt.Println(c.Id, c.ExternalUserId, c.ClientId, c.Scopes)
}
clientResourceshttps://github.com/scalekit-inc/scalekit-sdk-go/blob/main/resource.go
#asyncRevokeUserConsent

Revokes a single end-user consent held by a resource client. The client is prompted for consent again on its next authorization attempt, and every active refresh token issued to that client for the same user is revoked.

Access tokens that Scalekit already issued stay valid until they expire. See How revocation affects active access tokens for ways to shorten that window.

paramctxcontext.Context

Request context

paramclientIdstring

The resource client that holds the consent (format: m2m_...), not the resource ID.

paramconsentIdstring

The consent to revoke (format: usrcnst_...), taken from ListUserConsents.

returns*RevokeUserConsentResponse

Empty response on success. The call returns an error on failure.

if _, err := scalekitClient.Resources().RevokeUserConsent(ctx, "m2m_xxx", "usrcnst_789"); err != nil {
// handle error
}