Authorization: Bearer. On its own, the key reaches its own workspace. To reach another workspace, add its workspace ID, which goes in the workspaceId query parameter.
There is one key slot, so to add a workspace, set the key to both values with a newline between them:
apiKey and workspaceId options, which is clearer.
The plugin options are shared by every tenant and are read before the tenant’s stored key. Set apiKey and workspaceId only when every tenant really should reach the same U301 workspace; otherwise store the credential per account so each tenant gets its own. A stored bare key is composed with a configured workspaceId when one is present.
Things worth knowing before you rely on an answer:
- A new link spends one slot of the monthly allowance, and free accounts get 100 a month. Reusing a link does not: pass
reuseExistingto return the existing link for a URL instead of making a second one, and checkisReusedon the answer. An exhausted allowance answers429with theMONTHLY_LINK_LIMIT_REACHEDcode, which is never retried; a bare429is a throughput limit, and only replayable calls are retried afterRetry-After. - A link looks different on create than on read. A create answers
shortLink,urlandisReused; a read answersshortUrl,originalUrlandstatsClicks. The two shapes are modelled as they are rather than merged. - Links and domains are addressed by their own name, not an internal id.
links.gettakes the short form,u301.co/abc123, and it is sent as a path with its slash rather than an encoded%2F. Ahttps://prefix is stripped for you. - A custom domain is not live when it is created.
domains.createadds it, then you create the CNAME fromdnsSettings.cnameValueand polldomains.activeuntilactivedis true — that is U301’s own spelling of the field. A domain that is still verifying answersactived: falsewith a message such as “Challenge not ready”. - The three domain settings share one PATCH but are separate operations, so each sends exactly one field:
domains.pathLength(randomCodeLength, 3 to 10),domains.homeRedirectanddomains.notFoundRedirect. The two redirects are Pro plan features: a free workspace gets403“This feature is only available for Pro Plan”. - Analytics separate range from granularity.
rangeis how far back (24h,1d,3d,7d,14d,30d,60d,1m) andgranularityis how the buckets are cut (day,hour). Givetimezonewhen the day boundary matters. - The audience breakdown puts the dimension in the path.
analytics.audiencetakescountries,cities,referers,browsers,operating-systemsordevice-typesand calls the matchingtop-<dimension>route. Three of those are the provider’s own spellings, so they are not the words you might guess.
- 14 typed API operations
Setup
1
Install
2
Add the plugin
corsair.ts
multiTenancy: true, scope calls with corsair.withTenant(id). See Quick start for KEK + Hub keys, and Multi-tenancy for account isolation.3
Choose authentication
- API Key (Recommended)
No setup required yet. When you make your first request as a tenant, Corsair prompts for the API key.More: API Key
4
Connect a tenant
Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see Connect / OAuth.
Example API calls
List short links with their click countsWhat’s next
API reference
Every
u301.api.* operation with input and output types.Connect / OAuth
createLink, Hub delivery, and tenant connect flows.
Use with agents
Expose this plugin’s operations as MCP tools.