Skip to content

Authentication

The API takes a Bearer token in the Authorization header:

GET /v1/me HTTP/1.1
Host: api.sample.cloud
Authorization: Bearer sc_at_…

Catalog endpoints work without a token. Endpoints about the user (/v1/me and later the library) need one. A request with an invalid or expired token gets 401 with WWW-Authenticate: Bearer error="invalid_token"; it never falls back to anonymous access.

There are two ways for an app to get a token:

Device sign-in Pasted token
What the user does approves a code on sample.cloud creates a token on their account page and pastes it into the app
What the app needs network access to poll a text field
Lifetime access token 1 hour, refresh token 90 days (renewed on every refresh) what the user picked, up to 1 year
Prefix sc_at_, sc_rt_ sc_pat_

Use this in desktop apps and plugins. It needs no deep links, custom URL schemes or local ports: the app shows a code, the user approves it in any browser (even on another device), and the app polls until the sign-in is approved. The flow is RFC 8628.

Your app needs a client_id. Ask us to register it.

1. Start the sign-in

POST https://sample.cloud/oauth/device_authorization
Content-Type: application/x-www-form-urlencoded
client_id=app_…&scope=profile:read catalog:read library:read&device_name=Studio Mac&platform=macOS
{
"device_code": "KarohyPfqpr4cM7T00rxLN61OLO6AogQ4IB9VL-K-rQ",
"user_code": "NQJV-VMVP",
"verification_uri": "https://sample.cloud/device",
"verification_uri_complete": "https://sample.cloud/device?user_code=NQJV-VMVP",
"expires_in": 600,
"interval": 5
}

device_name and platform are optional. They are shown to the user on the approval page and in their list of signed-in apps, so make them recognisable.

2. Show the code and open the browser

Show user_code large, and open verification_uri_complete in the system browser (the code is already filled in there). Also show verification_uri as text, so the user can type it on another device. A QR code of verification_uri_complete works well on a phone.

3. Poll for the token

Every interval seconds:

POST https://sample.cloud/oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=urn:ietf:params:oauth:grant-type:device_code&client_id=app_…&device_code=Karohy…
Response Meaning What to do
400 {"error": "authorization_pending"} the user hasn’t approved it yet poll again after interval
400 {"error": "slow_down"} polling too fast add 5 seconds to the interval
400 {"error": "access_denied"} the user denied it stop, tell the user
400 {"error": "expired_token"} 10 minutes passed start again from step 1
200 with tokens approved store the tokens, stop polling
{
"access_token": "sc_at_…",
"token_type": "Bearer",
"expires_in": 3600,
"refresh_token": "sc_rt_…",
"scope": "profile:read catalog:read library:read"
}

Keep both tokens in the system secret store (Keychain, Windows Credential Manager, libsecret).

4. Refresh

When the access token expires (or the API answers 401), get a new pair:

POST https://sample.cloud/oauth/token
Content-Type: application/x-www-form-urlencoded
grant_type=refresh_token&client_id=app_…&refresh_token=sc_rt_…

Every refresh returns a new refresh token: store it and drop the old one. If an old refresh token is used again later, we treat it as stolen and sign the app out on that device. A retry within 30 seconds, after a lost response, is fine.

5. Sign out

POST https://sample.cloud/oauth/revoke
Content-Type: application/x-www-form-urlencoded
token=sc_rt_…

Revoking the refresh token ends the whole sign-in: all its tokens stop working within a minute. Users can also sign an app out on their account page.

For apps or scripts where the device sign-in is not an option. The user creates the token on https://sample.cloud/account#tokens, picks what it may do and how long it lives, and copies it once. The app sends it like any other Bearer token. It has no refresh: when it expires, the user makes a new one.

You can link the user to a prefilled form:

https://sample.cloud/account?token_name=My%20Plugin&scopes=profile:read,catalog:read#tokens

The format is sc_pat_ followed by 49 letters and digits. The last 6 are a checksum, so an app can reject a mistyped token before sending it.

Scope Gives
profile:read the user’s ID, name and handle (/v1/me)
profile:email the user’s email address
catalog:read browse and search the catalog
library:read the user’s kits and library
library:write create and change kits
downloads links to original files
generate generate sounds within the account’s daily limit, and publish them under CC0

A token never allows changing the email, the password or sign-in methods, managing tokens, or deleting the account. Those happen only on the site.

GET https://api.sample.cloud/v1/me
Authorization: Bearer sc_at_…
{
"id": "usr_…",
"object": "user",
"name": "…",
"handle": null,
"email": "…",
"created_at": "2026-12-03T11:12:14.205Z",
"token": { "type": "oauth", "scopes": ["profile:read", "profile:email"], "app_id": "app_…" }
}

email is there only with profile:email.

Endpoints, scopes and supported grants are published at https://sample.cloud/.well-known/oauth-authorization-server (RFC 8414). The same data, plus OpenID Connect fields, is at /.well-known/openid-configuration.