Your users

Label sandboxes with your own users, read usage by user, and cap what each may hold and spend

If you build a product on Pod, your users are Pod's end users. Name each one once by your own id for it, and Pod answers the same end user every time:

curl -X POST "https://api.pod.mapier.ai/v1/end_users" \
  -H "Authorization: Bearer $POD_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"ref": "user-1234"}'

Then:

  • Label sandboxes. Pass end_user when you create a sandbox. The label never changes afterwards.
  • Read usage by user. Read usage with group_by=end_user.
  • Cap each user. Set an end user's limits: how many sandboxes it may hold (max_sandboxes) and keep awake (max_awake). A create or wake past a limit answers quota_exceeded with the limit's name.
  • Cap what each user spends. Set an end user's spend cap: an amount a month in cents, with on_reach saying whether only new work is refused (refuse) or what is awake is also put to sleep (sleep). A person sets a default for every user of a project, and caps for the project and the organization, in the dashboard or with Set a spend cap. Once one is reached, creates and wakes under it answer spend_cap_reached. The spend is Pod's estimate from metered usage, worked out about every minute; your invoice is the bill.

One computer per user

If each of your users gets one computer, let the SDK find or make it. It answers the user's running sandbox, else one starting, else one asleep, which it wakes, and makes one when there is none:

const sandbox = await pod.endUsers.sandbox("user-1234", { create: { size: "small" } });

Two processes that ask at once make one sandbox between them: the create carries an idempotency key (Idempotency-Key) that both send alike. Send the same create fields from every process. A sandbox in error is never picked; it still counts against the user's limits until you delete it.

Name, tag and hold each user to a policy

Give a user a display_name, your own metadata and tags when you make it, or later with Change an end user; list end users by tag or state. The same call sets a policy every sandbox of the user is held to: wakes_per_hour, idle_s, the largest size (max_size) and the most vCPUs (max_vcpu). Pod holds the policy in every cell within seconds.

Suspend, resume and delete

Suspend an end user and its creates, wakes and tokens are refused with account_restricted (limit: end_user); what is awake is put to sleep unless you send "sleep": false. Resume it to lift that. Delete it and its sandboxes are deleted; its usage stays under its id, and your ref makes a new end user.

Tokens for your user's browser

Your server, with your key, can make a token for one user and hand it to that user's browser. The browser sends it as a bearer token and sees and drives only that user's sandboxes, with at most sandboxes:read, sandboxes:exec, files:read and files:write, for 30 seconds to an hour. A token is a secret: never log it. Revoke every token of a user at once; suspending or deleting the user refuses them too.

One key, narrowed to one user

Send the Pod-End-User header with an end user's id and the call sees only that user's sandboxes and usage; anything else answers not_found. Read the limits the same way to learn, before a create, whether it would be refused and why.

Your ref is yours: Pod stores it to find the end user again and shows it back to you. Do not use an email address or anything else personal as a ref.