Skip to content

List API Keys method 🪪 Sub-Accounts

Retrieves details of all API keys associated with the specified sub-account. For security reasons, the full API key is not returned; only the key ID and a partially redacted version are provided.

Usage

ts
import { MailChannelsClient, SubAccounts } from 'mailchannels-sdk'

const mailchannels = new MailChannelsClient('your-api-key')
const subAccounts = new SubAccounts(mailchannels)

const { data, error } = await subAccounts.listApiKeys('validhandle123')
ts
import { MailChannels } from 'mailchannels-sdk'

const mailchannels = new MailChannels('your-api-key')

const { data, error } = await mailchannels.subAccounts.listApiKeys('validhandle123')

Params

  • handle string required: The handle of the sub-account to retrieve the API keys for.
  • options SubAccountsListApiKeyOptions optional: List API keys options.
    • limit number optional: The maximum number of API keys included in the response. Possible values are 1 to 1000.
    • offset number optional: Offset into the list of API keys to return.

    TIP

    If no options are provided, the default limit is 100 and the offset is 0.

Response

  • data SubAccountsApiKey[] | null nullable
    • id number guaranteed: The API key ID for the sub-account.
    • key string guaranteed: API key for the sub-account.
  • error ErrorResponse | null nullable: Error information if the operation failed.
    • message string guaranteed: A human-readable description of the error.
    • statusCode number | null nullable: The HTTP status code from the API, or null if the error is not related to an HTTP request. This field is intended for diagnostic use only and should not be relied upon.
    • type string guaranteed: A string identifier for the type of error. This field is intended for diagnostic use only and should not be relied upon.

Type declarations

Signature

ts
async function listApiKeys (handle: string, options?: SubAccountsListApiKeyOptions): Promise<SubAccountsListApiKeyResponse>

Response type declarations

ts
interface ErrorResponse {
  message: string;
  statusCode: number | null;
  type: ErrorType;
}
ts
type DataResponse<T> = {
  data: T;
  error: null;
} | {
  data: null;
  error: ErrorResponse;
};

API Key type declarations

ts
interface SubAccountsApiKey {
  id: number;
  key: string;
}
ts
type SubAccountsListApiKeyResponse = DataResponse<SubAccountsApiKey[]>;

Source

SourcePlaygroundDocsTests

Released under the MIT License.