bun add @speakeasy-api/speakeasy-client-sdk-typescript
Yarn
yarn add @speakeasy-api/speakeasy-client-sdk-typescript zod
# Note that Yarn does not install peer dependencies automatically. You will need# to install zod as shown above.
SDK Example Usage
Example
import{Speakeasy}from"@speakeasy-api/speakeasy-client-sdk-typescript";constspeakeasy=newSpeakeasy({security:{apiKey:"<YOUR_API_KEY_HERE>",},});asyncfunctionrun(){constresult=awaitspeakeasy.apis.getApis({});// Handle the resultconsole.log(result);}run();
Available Resources and Operations
Available methods
### [apiEndpoints](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/)
* [deleteApiEndpoint](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#deleteapiendpoint) - Delete an ApiEndpoint.
* [findApiEndpoint](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#findapiendpoint) - Find an ApiEndpoint via its displayName.
* [generateOpenApiSpecForApiEndpoint](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#generateopenapispecforapiendpoint) - Generate an OpenAPI specification for a particular ApiEndpoint.
* [generatePostmanCollectionForApiEndpoint](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#generatepostmancollectionforapiendpoint) - Generate a Postman collection for a particular ApiEndpoint.
* [getAllApiEndpoints](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#getallapiendpoints) - Get all Api endpoints for a particular apiID.
* [getAllForVersionApiEndpoints](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#getallforversionapiendpoints) - Get all ApiEndpoints for a particular apiID and versionID.
* [getApiEndpoint](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#getapiendpoint) - Get an ApiEndpoint.
* [upsertApiEndpoint](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#upsertapiendpoint) - Upsert an ApiEndpoint.
### [apis](/speakeasy-client-sdk-typescript/docs/sdks/apis/)
* [deleteApi](/speakeasy-client-sdk-typescript/docs/sdks/apis/#deleteapi) - Delete an Api.
* [generateOpenApiSpec](/speakeasy-client-sdk-typescript/docs/sdks/apis/#generateopenapispec) - Generate an OpenAPI specification for a particular Api.
* [generatePostmanCollection](/speakeasy-client-sdk-typescript/docs/sdks/apis/#generatepostmancollection) - Generate a Postman collection for a particular Api.
* [getAllApiVersions](/speakeasy-client-sdk-typescript/docs/sdks/apis/#getallapiversions) - Get all Api versions for a particular ApiEndpoint.
* [getApis](/speakeasy-client-sdk-typescript/docs/sdks/apis/#getapis) - Get a list of Apis for a given workspace
* [upsertApi](/speakeasy-client-sdk-typescript/docs/sdks/apis/#upsertapi) - Upsert an Api
### [artifacts](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/)
* [getBlob](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/#getblob) - Get blob for a particular digest
* [getManifest](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/#getmanifest) - Get manifest for a particular reference
* [getNamespaces](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/#getnamespaces) - Each namespace contains many revisions.
* [getRevisions](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/#getrevisions)
* [getTags](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/#gettags)
* [postTags](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/#posttags) - Add tags to an existing revision
* [preflight](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/#preflight) - Get access token for communicating with OCI distribution endpoints
### [auth](/speakeasy-client-sdk-typescript/docs/sdks/auth/)
* [getAccess](/speakeasy-client-sdk-typescript/docs/sdks/auth/#getaccess) - Get access allowances for a particular workspace
* [getAccessToken](/speakeasy-client-sdk-typescript/docs/sdks/auth/#getaccesstoken) - Get or refresh an access token for the current workspace.
* [getUser](/speakeasy-client-sdk-typescript/docs/sdks/auth/#getuser) - Get information about the current user.
* [validateApiKey](/speakeasy-client-sdk-typescript/docs/sdks/auth/#validateapikey) - Validate the current api key.
### [embeds](/speakeasy-client-sdk-typescript/docs/sdks/embeds/)
* [getEmbedAccessToken](/speakeasy-client-sdk-typescript/docs/sdks/embeds/#getembedaccesstoken) - Get an embed access token for the current workspace.
* [getValidEmbedAccessTokens](/speakeasy-client-sdk-typescript/docs/sdks/embeds/#getvalidembedaccesstokens) - Get all valid embed access tokens for the current workspace.
* [revokeEmbedAccessToken](/speakeasy-client-sdk-typescript/docs/sdks/embeds/#revokeembedaccesstoken) - Revoke an embed access EmbedToken.
### [events](/speakeasy-client-sdk-typescript/docs/sdks/events/)
* [getEventsByTarget](/speakeasy-client-sdk-typescript/docs/sdks/events/#geteventsbytarget) - Load recent events for a particular workspace
* [getTargets](/speakeasy-client-sdk-typescript/docs/sdks/events/#gettargets) - Load targets for a particular workspace
* [getTargetsDeprecated](/speakeasy-client-sdk-typescript/docs/sdks/events/#gettargetsdeprecated) - Load targets for a particular workspace
* [post](/speakeasy-client-sdk-typescript/docs/sdks/events/#post) - Post events for a specific workspace
* [search](/speakeasy-client-sdk-typescript/docs/sdks/events/#search) - Search events for a particular workspace by any field
### [github](/speakeasy-client-sdk-typescript/docs/sdks/github/)
* [checkAccess](/speakeasy-client-sdk-typescript/docs/sdks/github/#checkaccess)
* [checkPublishingPRs](/speakeasy-client-sdk-typescript/docs/sdks/github/#checkpublishingprs)
* [checkPublishingSecrets](/speakeasy-client-sdk-typescript/docs/sdks/github/#checkpublishingsecrets)
* [configureCodeSamples](/speakeasy-client-sdk-typescript/docs/sdks/github/#configurecodesamples)
* [configureMintlifyRepo](/speakeasy-client-sdk-typescript/docs/sdks/github/#configuremintlifyrepo)
* [configureTarget](/speakeasy-client-sdk-typescript/docs/sdks/github/#configuretarget)
* [getAction](/speakeasy-client-sdk-typescript/docs/sdks/github/#getaction)
* [storePublishingSecrets](/speakeasy-client-sdk-typescript/docs/sdks/github/#storepublishingsecrets)
* [triggerAction](/speakeasy-client-sdk-typescript/docs/sdks/github/#triggeraction)
### [metadata](/speakeasy-client-sdk-typescript/docs/sdks/metadata/)
* [deleteVersionMetadata](/speakeasy-client-sdk-typescript/docs/sdks/metadata/#deleteversionmetadata) - Delete metadata for a particular apiID and versionID.
* [getVersionMetadata](/speakeasy-client-sdk-typescript/docs/sdks/metadata/#getversionmetadata) - Get all metadata for a particular apiID and versionID.
* [insertVersionMetadata](/speakeasy-client-sdk-typescript/docs/sdks/metadata/#insertversionmetadata) - Insert metadata for a particular apiID and versionID.
### [organizations](/speakeasy-client-sdk-typescript/docs/sdks/organizations/)
* [create](/speakeasy-client-sdk-typescript/docs/sdks/organizations/#create) - Create an organization
* [createFreeTrial](/speakeasy-client-sdk-typescript/docs/sdks/organizations/#createfreetrial) - Create a free trial for an organization
* [get](/speakeasy-client-sdk-typescript/docs/sdks/organizations/#get) - Get organization
* [getAll](/speakeasy-client-sdk-typescript/docs/sdks/organizations/#getall) - Get organizations for a user
* [getUsage](/speakeasy-client-sdk-typescript/docs/sdks/organizations/#getusage) - Get billing usage summary for a particular organization
### [reports](/speakeasy-client-sdk-typescript/docs/sdks/reports/)
* [getChangesReportSignedUrl](/speakeasy-client-sdk-typescript/docs/sdks/reports/#getchangesreportsignedurl) - Get the signed access url for the change reports for a particular document.
* [getLintingReportSignedUrl](/speakeasy-client-sdk-typescript/docs/sdks/reports/#getlintingreportsignedurl) - Get the signed access url for the linting reports for a particular document.
* [uploadReport](/speakeasy-client-sdk-typescript/docs/sdks/reports/#uploadreport) - Upload a report.
### [requests](/speakeasy-client-sdk-typescript/docs/sdks/requests/)
* [generateRequestPostmanCollection](/speakeasy-client-sdk-typescript/docs/sdks/requests/#generaterequestpostmancollection) - Generate a Postman collection for a particular request.
* [getRequestFromEventLog](/speakeasy-client-sdk-typescript/docs/sdks/requests/#getrequestfromeventlog) - Get information about a particular request.
* [queryEventLog](/speakeasy-client-sdk-typescript/docs/sdks/requests/#queryeventlog) - Query the event log to retrieve a list of requests.
### [schemas](/speakeasy-client-sdk-typescript/docs/sdks/schemas/)
* [deleteSchema](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#deleteschema) - Delete a particular schema revision for an Api.
* [downloadSchema](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#downloadschema) - Download the latest schema for a particular apiID.
* [downloadSchemaRevision](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#downloadschemarevision) - Download a particular schema revision for an Api.
* [getSchema](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#getschema) - Get information about the latest schema.
* [getSchemaDiff](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#getschemadiff) - Get a diff of two schema revisions for an Api.
* [getSchemaRevision](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#getschemarevision) - Get information about a particular schema revision for an Api.
* [getSchemas](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#getschemas) - Get information about all schemas associated with a particular apiID.
* [registerSchema](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#registerschema) - Register a schema.
### [shortURLs](/speakeasy-client-sdk-typescript/docs/sdks/shorturls/)
* [create](/speakeasy-client-sdk-typescript/docs/sdks/shorturls/#create) - Shorten a URL.
### [suggest](/speakeasy-client-sdk-typescript/docs/sdks/suggest/)
* [suggest](/speakeasy-client-sdk-typescript/docs/sdks/suggest/#suggest) - Generate suggestions for improving an OpenAPI document.
* [suggestOpenAPI](/speakeasy-client-sdk-typescript/docs/sdks/suggest/#suggestopenapi) - (DEPRECATED) Generate suggestions for improving an OpenAPI document.
* [suggestOpenAPIRegistry](/speakeasy-client-sdk-typescript/docs/sdks/suggest/#suggestopenapiregistry) - Generate suggestions for improving an OpenAPI document stored in the registry.
### [workspaces](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/)
* [create](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#create) - Create a workspace
* [createToken](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#createtoken) - Create a token for a particular workspace
* [deleteToken](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#deletetoken) - Delete a token for a particular workspace
* [get](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#get) - Get workspace by context
* [getAll](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#getall) - Get workspaces for a user
* [getByID](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#getbyid) - Get workspace
* [getFeatureFlags](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#getfeatureflags) - Get workspace feature flags
* [getSettings](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#getsettings) - Get workspace settings
* [getTeam](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#getteam) - Get team members for a particular workspace
* [getTokens](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#gettokens) - Get tokens for a particular workspace
* [grantAccess](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#grantaccess) - Grant a user access to a particular workspace
* [revokeAccess](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#revokeaccess) - Revoke a user's access to a particular workspace
* [update](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#update) - Update workspace details
* [updateSettings](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#updatesettings) - Update workspace settings
Error Handling
All SDK methods return a response object or throw an error. By default, an API error will throw a errors.SDKError.
If a HTTP request fails, an operation my also throw an error from the sdk/models/errors/httpclienterrors.ts module:
HTTP Client Error
Description
RequestAbortedError
HTTP request was aborted by the client
RequestTimeoutError
HTTP request timed out due to an AbortSignal signal
ConnectionError
HTTP client was unable to make a request to a server
InvalidRequestError
Any input used to create a request is invalid
UnexpectedClientError
Unrecognised or unexpected error
In addition, when custom error responses are specified for an operation, the SDK may throw their associated Error type. You can refer to respective Errors tables in SDK docs for more details on possible error types for each operation. For example, the deleteApi method may throw the following errors:
Error Type
Status Code
Content Type
errors.SDKError
4XX, 5XX
*/*
import{Speakeasy}from"@speakeasy-api/speakeasy-client-sdk-typescript";import{SDKValidationError}from"@speakeasy-api/speakeasy-client-sdk-typescript/sdk/models/errors";constspeakeasy=newSpeakeasy({security:{apiKey:"<YOUR_API_KEY_HERE>",},});asyncfunctionrun(){letresult;try{result=awaitspeakeasy.apis.deleteApi({apiID:"<id>",versionID:"<id>",});// Handle the resultconsole.log(result);}catch(err){switch(true){case(errinstanceofSDKValidationError):{// Validation errors can be pretty-printedconsole.error(err.pretty());// Raw value may also be inspectedconsole.error(err.rawValue);return;}default:{throwerr;}}}}run();
Validation errors can also occur when either method arguments or data returned from the server do not match the expected format. The SDKValidationError that is thrown as a result will capture the raw value that failed validation in an attribute called rawValue. Additionally, a pretty() method is available on this error that can be used to log a nicely formatted string since validation errors can list many issues and the plain error string may be difficult read when debugging.
Server Selection
Select Server by Name
You can override the default server globally by passing a server name to the server optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
Name
Server
Variables
prod
https://api.prod.speakeasyapi.dev
None
import{Speakeasy}from"@speakeasy-api/speakeasy-client-sdk-typescript";constspeakeasy=newSpeakeasy({server:"prod",security:{apiKey:"<YOUR_API_KEY_HERE>",},});asyncfunctionrun(){constresult=awaitspeakeasy.apis.deleteApi({apiID:"<id>",versionID:"<id>",});// Handle the resultconsole.log(result);}run();
Override Server URL Per-Client
The default server can also be overridden globally by passing a URL to the serverURL optional parameter when initializing the SDK client instance. For example:
import{Speakeasy}from"@speakeasy-api/speakeasy-client-sdk-typescript";constspeakeasy=newSpeakeasy({serverURL:"https://api.prod.speakeasyapi.dev",security:{apiKey:"<YOUR_API_KEY_HERE>",},});asyncfunctionrun(){constresult=awaitspeakeasy.apis.deleteApi({apiID:"<id>",versionID:"<id>",});// Handle the resultconsole.log(result);}run();
Custom HTTP Client
The TypeScript SDK makes API calls using an HTTPClient that wraps the native
Fetch API. This
client is a thin wrapper around fetch and provides the ability to attach hooks
around the request lifecycle that can be used to modify the request or handle
errors and response.
The HTTPClient constructor takes an optional fetcher argument that can be
used to integrate a third-party HTTP client or when writing tests to mock out
the HTTP client and feed in fixtures.
The following example shows how to use the "beforeRequest" hook to to add a
custom header and a timeout to requests and how to use the "requestError" hook
to log errors:
import{Speakeasy}from"@speakeasy-api/speakeasy-client-sdk-typescript";import{HTTPClient}from"@speakeasy-api/speakeasy-client-sdk-typescript/lib/http";consthttpClient=newHTTPClient({// fetcher takes a function that has the same signature as native `fetch`.fetcher:(request)=>{returnfetch(request);}});httpClient.addHook("beforeRequest",(request)=>{constnextRequest=newRequest(request,{signal:request.signal||AbortSignal.timeout(5000)});nextRequest.headers.set("x-custom-header","custom value");returnnextRequest;});httpClient.addHook("requestError",(error,request)=>{console.group("Request Error");console.log("Reason:",`${error}`);console.log("Endpoint:",`${request.method}${request.url}`);console.groupEnd();});constsdk=newSpeakeasy({httpClient});
Authentication
Per-Client Security Schemes
This SDK supports the following security schemes globally:
Name
Type
Scheme
apiKey
apiKey
API key
bearer
http
HTTP Bearer
workspaceIdentifier
apiKey
API key
You can set the security parameters through the security optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:
import{Speakeasy}from"@speakeasy-api/speakeasy-client-sdk-typescript";constspeakeasy=newSpeakeasy({security:{apiKey:"<YOUR_API_KEY_HERE>",},});asyncfunctionrun(){constresult=awaitspeakeasy.apis.deleteApi({apiID:"<id>",versionID:"<id>",});// Handle the resultconsole.log(result);}run();
Retries
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
To change the default retry strategy for a single API call, simply provide a retryConfig object to the call:
import{Speakeasy}from"@speakeasy-api/speakeasy-client-sdk-typescript";constspeakeasy=newSpeakeasy({security:{apiKey:"<YOUR_API_KEY_HERE>",},});asyncfunctionrun(){constresult=awaitspeakeasy.apis.deleteApi({apiID:"<id>",versionID:"<id>",},{retries:{strategy:"backoff",backoff:{initialInterval:1,maxInterval:50,exponent:1.1,maxElapsedTime:100,},retryConnectionErrors:false,},});// Handle the resultconsole.log(result);}run();
If you’d like to override the default retry strategy for all operations that support retries, you can provide a retryConfig at SDK initialization:
import{Speakeasy}from"@speakeasy-api/speakeasy-client-sdk-typescript";constspeakeasy=newSpeakeasy({retryConfig:{strategy:"backoff",backoff:{initialInterval:1,maxInterval:50,exponent:1.1,maxElapsedTime:100,},retryConnectionErrors:false,},security:{apiKey:"<YOUR_API_KEY_HERE>",},});asyncfunctionrun(){constresult=awaitspeakeasy.apis.deleteApi({apiID:"<id>",versionID:"<id>",});// Handle the resultconsole.log(result);}run();
Requirements
For supported JavaScript runtimes, please consult RUNTIMES.md.
Standalone functions
All the methods listed above are available as standalone functions. These
functions are ideal for use in applications running in the browser, serverless
runtimes or other environments where application bundle size is a primary
concern. When using a bundler to build your application, all unused
functionality will be either excluded from the final bundle or tree-shaken away.
To read more about standalone functions, check FUNCTIONS.md.
Available standalone functions
- [`apiEndpointsDeleteApiEndpoint`](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#deleteapiendpoint) - Delete an ApiEndpoint.
- [`apiEndpointsFindApiEndpoint`](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#findapiendpoint) - Find an ApiEndpoint via its displayName.
- [`apiEndpointsGenerateOpenApiSpecForApiEndpoint`](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#generateopenapispecforapiendpoint) - Generate an OpenAPI specification for a particular ApiEndpoint.
- [`apiEndpointsGeneratePostmanCollectionForApiEndpoint`](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#generatepostmancollectionforapiendpoint) - Generate a Postman collection for a particular ApiEndpoint.
- [`apiEndpointsGetAllApiEndpoints`](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#getallapiendpoints) - Get all Api endpoints for a particular apiID.
- [`apiEndpointsGetAllForVersionApiEndpoints`](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#getallforversionapiendpoints) - Get all ApiEndpoints for a particular apiID and versionID.
- [`apiEndpointsGetApiEndpoint`](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#getapiendpoint) - Get an ApiEndpoint.
- [`apiEndpointsUpsertApiEndpoint`](/speakeasy-client-sdk-typescript/docs/sdks/apiendpoints/#upsertapiendpoint) - Upsert an ApiEndpoint.
- [`apisDeleteApi`](/speakeasy-client-sdk-typescript/docs/sdks/apis/#deleteapi) - Delete an Api.
- [`apisGenerateOpenApiSpec`](/speakeasy-client-sdk-typescript/docs/sdks/apis/#generateopenapispec) - Generate an OpenAPI specification for a particular Api.
- [`apisGeneratePostmanCollection`](/speakeasy-client-sdk-typescript/docs/sdks/apis/#generatepostmancollection) - Generate a Postman collection for a particular Api.
- [`apisGetAllApiVersions`](/speakeasy-client-sdk-typescript/docs/sdks/apis/#getallapiversions) - Get all Api versions for a particular ApiEndpoint.
- [`apisGetApis`](/speakeasy-client-sdk-typescript/docs/sdks/apis/#getapis) - Get a list of Apis for a given workspace
- [`apisUpsertApi`](/speakeasy-client-sdk-typescript/docs/sdks/apis/#upsertapi) - Upsert an Api
- [`artifactsGetBlob`](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/#getblob) - Get blob for a particular digest
- [`artifactsGetManifest`](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/#getmanifest) - Get manifest for a particular reference
- [`artifactsGetNamespaces`](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/#getnamespaces) - Each namespace contains many revisions.
- [`artifactsGetRevisions`](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/#getrevisions)
- [`artifactsGetTags`](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/#gettags)
- [`artifactsPostTags`](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/#posttags) - Add tags to an existing revision
- [`artifactsPreflight`](/speakeasy-client-sdk-typescript/docs/sdks/artifacts/#preflight) - Get access token for communicating with OCI distribution endpoints
- [`authGetAccess`](/speakeasy-client-sdk-typescript/docs/sdks/auth/#getaccess) - Get access allowances for a particular workspace
- [`authGetAccessToken`](/speakeasy-client-sdk-typescript/docs/sdks/auth/#getaccesstoken) - Get or refresh an access token for the current workspace.
- [`authGetUser`](/speakeasy-client-sdk-typescript/docs/sdks/auth/#getuser) - Get information about the current user.
- [`authValidateApiKey`](/speakeasy-client-sdk-typescript/docs/sdks/auth/#validateapikey) - Validate the current api key.
- [`embedsGetEmbedAccessToken`](/speakeasy-client-sdk-typescript/docs/sdks/embeds/#getembedaccesstoken) - Get an embed access token for the current workspace.
- [`embedsGetValidEmbedAccessTokens`](/speakeasy-client-sdk-typescript/docs/sdks/embeds/#getvalidembedaccesstokens) - Get all valid embed access tokens for the current workspace.
- [`embedsRevokeEmbedAccessToken`](/speakeasy-client-sdk-typescript/docs/sdks/embeds/#revokeembedaccesstoken) - Revoke an embed access EmbedToken.
- [`eventsGetEventsByTarget`](/speakeasy-client-sdk-typescript/docs/sdks/events/#geteventsbytarget) - Load recent events for a particular workspace
- [`eventsGetTargets`](/speakeasy-client-sdk-typescript/docs/sdks/events/#gettargets) - Load targets for a particular workspace
- [`eventsGetTargetsDeprecated`](/speakeasy-client-sdk-typescript/docs/sdks/events/#gettargetsdeprecated) - Load targets for a particular workspace
- [`eventsPost`](/speakeasy-client-sdk-typescript/docs/sdks/events/#post) - Post events for a specific workspace
- [`eventsSearch`](/speakeasy-client-sdk-typescript/docs/sdks/events/#search) - Search events for a particular workspace by any field
- [`githubCheckAccess`](/speakeasy-client-sdk-typescript/docs/sdks/github/#checkaccess)
- [`githubCheckPublishingPRs`](/speakeasy-client-sdk-typescript/docs/sdks/github/#checkpublishingprs)
- [`githubCheckPublishingSecrets`](/speakeasy-client-sdk-typescript/docs/sdks/github/#checkpublishingsecrets)
- [`githubConfigureCodeSamples`](/speakeasy-client-sdk-typescript/docs/sdks/github/#configurecodesamples)
- [`githubConfigureMintlifyRepo`](/speakeasy-client-sdk-typescript/docs/sdks/github/#configuremintlifyrepo)
- [`githubConfigureTarget`](/speakeasy-client-sdk-typescript/docs/sdks/github/#configuretarget)
- [`githubGetAction`](/speakeasy-client-sdk-typescript/docs/sdks/github/#getaction)
- [`githubStorePublishingSecrets`](/speakeasy-client-sdk-typescript/docs/sdks/github/#storepublishingsecrets)
- [`githubTriggerAction`](/speakeasy-client-sdk-typescript/docs/sdks/github/#triggeraction)
- [`metadataDeleteVersionMetadata`](/speakeasy-client-sdk-typescript/docs/sdks/metadata/#deleteversionmetadata) - Delete metadata for a particular apiID and versionID.
- [`metadataGetVersionMetadata`](/speakeasy-client-sdk-typescript/docs/sdks/metadata/#getversionmetadata) - Get all metadata for a particular apiID and versionID.
- [`metadataInsertVersionMetadata`](/speakeasy-client-sdk-typescript/docs/sdks/metadata/#insertversionmetadata) - Insert metadata for a particular apiID and versionID.
- [`organizationsCreate`](/speakeasy-client-sdk-typescript/docs/sdks/organizations/#create) - Create an organization
- [`organizationsCreateFreeTrial`](/speakeasy-client-sdk-typescript/docs/sdks/organizations/#createfreetrial) - Create a free trial for an organization
- [`organizationsGet`](/speakeasy-client-sdk-typescript/docs/sdks/organizations/#get) - Get organization
- [`organizationsGetAll`](/speakeasy-client-sdk-typescript/docs/sdks/organizations/#getall) - Get organizations for a user
- [`organizationsGetUsage`](/speakeasy-client-sdk-typescript/docs/sdks/organizations/#getusage) - Get billing usage summary for a particular organization
- [`reportsGetChangesReportSignedUrl`](/speakeasy-client-sdk-typescript/docs/sdks/reports/#getchangesreportsignedurl) - Get the signed access url for the change reports for a particular document.
- [`reportsGetLintingReportSignedUrl`](/speakeasy-client-sdk-typescript/docs/sdks/reports/#getlintingreportsignedurl) - Get the signed access url for the linting reports for a particular document.
- [`reportsUploadReport`](/speakeasy-client-sdk-typescript/docs/sdks/reports/#uploadreport) - Upload a report.
- [`requestsGenerateRequestPostmanCollection`](/speakeasy-client-sdk-typescript/docs/sdks/requests/#generaterequestpostmancollection) - Generate a Postman collection for a particular request.
- [`requestsGetRequestFromEventLog`](/speakeasy-client-sdk-typescript/docs/sdks/requests/#getrequestfromeventlog) - Get information about a particular request.
- [`requestsQueryEventLog`](/speakeasy-client-sdk-typescript/docs/sdks/requests/#queryeventlog) - Query the event log to retrieve a list of requests.
- [`schemasDeleteSchema`](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#deleteschema) - Delete a particular schema revision for an Api.
- [`schemasDownloadSchema`](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#downloadschema) - Download the latest schema for a particular apiID.
- [`schemasDownloadSchemaRevision`](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#downloadschemarevision) - Download a particular schema revision for an Api.
- [`schemasGetSchema`](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#getschema) - Get information about the latest schema.
- [`schemasGetSchemaDiff`](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#getschemadiff) - Get a diff of two schema revisions for an Api.
- [`schemasGetSchemaRevision`](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#getschemarevision) - Get information about a particular schema revision for an Api.
- [`schemasGetSchemas`](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#getschemas) - Get information about all schemas associated with a particular apiID.
- [`schemasRegisterSchema`](/speakeasy-client-sdk-typescript/docs/sdks/schemas/#registerschema) - Register a schema.
- [`shortURLsCreate`](/speakeasy-client-sdk-typescript/docs/sdks/shorturls/#create) - Shorten a URL.
- [`suggestSuggest`](/speakeasy-client-sdk-typescript/docs/sdks/suggest/#suggest) - Generate suggestions for improving an OpenAPI document.
- [`suggestSuggestOpenAPI`](/speakeasy-client-sdk-typescript/docs/sdks/suggest/#suggestopenapi) - (DEPRECATED) Generate suggestions for improving an OpenAPI document.
- [`suggestSuggestOpenAPIRegistry`](/speakeasy-client-sdk-typescript/docs/sdks/suggest/#suggestopenapiregistry) - Generate suggestions for improving an OpenAPI document stored in the registry.
- [`workspacesCreate`](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#create) - Create a workspace
- [`workspacesCreateToken`](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#createtoken) - Create a token for a particular workspace
- [`workspacesDeleteToken`](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#deletetoken) - Delete a token for a particular workspace
- [`workspacesGet`](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#get) - Get workspace by context
- [`workspacesGetAll`](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#getall) - Get workspaces for a user
- [`workspacesGetByID`](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#getbyid) - Get workspace
- [`workspacesGetFeatureFlags`](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#getfeatureflags) - Get workspace feature flags
- [`workspacesGetSettings`](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#getsettings) - Get workspace settings
- [`workspacesGetTeam`](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#getteam) - Get team members for a particular workspace
- [`workspacesGetTokens`](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#gettokens) - Get tokens for a particular workspace
- [`workspacesGrantAccess`](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#grantaccess) - Grant a user access to a particular workspace
- [`workspacesRevokeAccess`](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#revokeaccess) - Revoke a user's access to a particular workspace
- [`workspacesUpdate`](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#update) - Update workspace details
- [`workspacesUpdateSettings`](/speakeasy-client-sdk-typescript/docs/sdks/workspaces/#updatesettings) - Update workspace settings
File uploads
Certain SDK methods accept files as part of a multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
[!TIP]
Depending on your JavaScript runtime, there are convenient utilities that return a handle to a file without reading the entire contents into memory:
Node.js v20+: Since v20, Node.js comes with a native openAsBlob function in node:fs.
Bun: The native Bun.file function produces a file handle that can be used for streaming file uploads.
Browsers: All supported browsers return an instance to a File when reading the value from an <input type="file"> element.
Node.js v18: A file stream can be created using the fileFrom helper from fetch-blob/from.js.
import{Speakeasy}from"@speakeasy-api/speakeasy-client-sdk-typescript";import{openAsBlob}from"node:fs";constspeakeasy=newSpeakeasy({security:{apiKey:"<YOUR_API_KEY_HERE>",},});asyncfunctionrun(){constresult=awaitspeakeasy.schemas.registerSchema({apiID:"<id>",versionID:"<id>",requestBody:{file:awaitopenAsBlob("example.file"),},});// Handle the resultconsole.log(result);}run();
Debugging
You can setup your SDK to emit debug logs for SDK requests and responses.
You can pass a logger that matches console’s interface as an SDK option.
[!WARNING]
Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It’s recommended to use this feature only during local development and not in production.