Skip to main content
This page lists every method of the client, the operation each one calls, and the value it resolves with. Use it to find the method for an operation, then follow the link to the operation’s reference page for its parameters, its fields and its errors.

Conventions

A client exposes one property per resource, such as client.messages, and three methods of its own. Every method follows the same rules:
  • Arguments. Path parameters come first, then the request body or the query, then an optional options object. The SDK URL-encodes path parameters.
  • Bodies. A request body is sent as given. Field names are the snake_case names of the API: the SDK converts no name.
  • Queries. A query value that is undefined or null is left out. Every other value is sent as a string.
  • Result. A successful call resolves with the data of the response. The HTTP status, the response headers, and the trace_id and request_id of the response are not available on success. A 200 cannot be told from a 201 or a 202.
  • No content. A 204 response resolves with undefined.
  • Failure. A failed call throws: see Errors and retries.

Methods

Client

Messages

Chats

Attachments

Recipient lookup

lookup.check resolves the same way on a final result and on a pending one. A pending result has pending: true, with probe_id and retry_after: repeat the call after retry_after seconds.

Lines

lines.mintShared, lines.activate and lines.terminate send {} when you give no body.

Webhook subscriptions

webhooks.replay replays one delivery. It takes the id of a webhook subscription and the id of a delivery, not the id of an event.

Trials

trial.init and trial.revoke send {} when you give no body. trial.status(token) puts the pairing code of the trial in the URL of the request. Treat the pairing code as a secret, and do not log request URLs. trial.activity is called with a trial key: create a second client for it.

BYOD

Pre-orders

Hosted macOS sessions

macosSessions.rent accepts rent(), rent(opts) and rent({ metadata }, opts). The first argument is read as a body only when it has a metadata key.

Operations with no method

One operation of the API reference has no method: GET /v1/attention. Call it with client.request. API keys are created and revoked in the iSnap dashboard. The SDK has no method for them.

The attachments helper

attachments.upload(file, { filename, contentType }, opts?) does three things in one call. It registers the attachment with POST /v1/attachments, uploads the bytes to the URL that operation returns, then polls GET /v1/attachments/{id} until the attachment is ready. It resolves with that attachment. To send the file, pass its id in the attachments array of messages.send. opts also takes the per-call options. Each upload() call registers a new attachment, unless you pass an idempotencyKey that an earlier call used: the API then returns the attachment registered with that key while it is awaiting_upload and before its upload deadline, and 409 idempotency_terminal_state in any other state. Pass a new key for each file.

Polling

With the defaults the helper polls 60 times, 500 ms apart: 30 seconds of waiting, plus the time of the requests. After the last poll it throws APIError with status 504 and code upload_timeout. iSnap confirms a finished upload on a 30-second cycle, and converts an audio file before the attachment is ready. The default polling, 60 polls 500 milliseconds apart, can therefore end on an upload that succeeds. Raise pollIntervalMs to 2,000 to 5,000 milliseconds, so that maxPolls polls cover at least 60 seconds. Each poll is one API request, plus its automatic retries when it fails. Each request counts against the request-rate limit, 100 requests per rolling 60 seconds. At the default interval, with no retry, the helper makes up to 2 requests per second: raising maxPolls alone can make up to 120 requests per minute. A timeout does not cancel the attachment.

Failures

The upload request is sent once and is not retried. It has the timeoutMs of the client: a large file needs a larger timeoutMs. When the helper throws, it gives you no attachment id: on upload_timeout, and on upload_failed with status 422, the id is in the text of the error message only. A refused upload carries no id. To keep the id, call attachments.create, upload the bytes yourself, and poll attachments.get. Example: uploading an attachment shows both ways, and Attachments gives the limits and the retention of a file.

Health and version

The two operations need no credential. The client sends its key with them as with every request.

Exports

The package exports 41 values, and its request, response and event types by name. The request and response types are generated from the OpenAPI document. Their fields are the snake_case fields of the API. The generated paths and components types are not exported. TypeScript rejects a request field that is not in the API. In plain JavaScript nothing checks the field names: a misspelled field is sent as given. Nine operations refuse a field they do not define with 400 validation_failed, and every other operation ignores it, as POST /v1/messages does: see Requests.

Versions

The SDK follows Semantic Versioning. It sends no API version and negotiates none: client.version() returns the version of the API the client talks to. Versioning and compatibility gives the version scheme of the API.

Personal data

The SDK stores nothing. It passes handles, message text and metadata through as given. Many methods return them: the message, chat, trial and lookup methods, and the webhook events. Request this data only when needed. Do not copy it into logs, tickets or other tools, and refer to a contact by an id of your own.