Skip to main content
See Services for usage and limits.

Service

Properties use the last response without making a request.

Static methods

Service.builder()

Start a ServiceBuilder.

Parameters

slugstring
Service slug, e.g. “my-app”.

Returns

Builder for the new Service.

Service.get()

Get a Service by slug.

Parameters

slugstring
Service slug.

Returns

The Service’s current state.

Service.list()

List the first page in slug order, including disabled and detached Services.

Returns

One page of Services.

Service.listWith()

List a configured page in slug order. A limit outside 1 through 100 throws RangeError before any request.

Parameters

configure(list: ServiceListBuilder) => ServiceListBuilder
Sets the list options.

Returns

One page of Services.

Instance properties

svc.slug

string The Service slug.

svc.url

string The public URL as returned by the backend.

svc.status

ServiceStatus Whether the Service routes requests, is disabled, or has no target, as of the read that returned this value. refresh() returns a current copy.

svc.target

ServiceTarget | null The target, or null when the Service is detached.

svc.createdAt

Date The creation time.

svc.updatedAt

Date The last state-change time.

Instance methods

svc.update()

Change the target without retrying. If changed is “unknown”, get and check the Service.

Parameters

Required target for the change.

Returns

The Service as committed.

svc.enable()

Enable the Service without retrying. To enable a detached Service, set a running target with update() instead.

svc.disable()

Disable the Service without retrying while retaining its target.

svc.remove()

Remove the Service and release its slug without retrying.

svc.refresh()

Get the Service again and return its current state. This value is not changed.

Returns

The Service’s current state.

ServiceBuilder

builder.target()

Set the running sandbox and port that receive requests.

Parameters

sandboxstring
Target sandbox name.
portnumber
Sandbox port, 1 through 65535.

builder.create()

Create the Service without retrying. A port that is not an integer from 1 through 65535 throws RangeError; a missing target throws InvalidConfigError. Both errors occur before any request. Repeating a create with the same slug and target returns the existing Service while it is enabled.

Returns

The Service as committed.

ServiceUpdateOptions

Options for one target update. The target is required. A port that is not an integer from 1 through 65535 throws RangeError before any request.

target

Set the running target. This also enables or reattaches the Service. See ServiceTarget for its fields.

ServiceListBuilder

l.sandbox()

Filter by target sandbox. An unknown name returns an empty page.

Parameters

namestring
Sandbox name.

l.limit()

Set the page size from 1 to 100; the default is 20.

Parameters

limitnumber
Page size.

l.cursor()

Continue from a previous nextCursor.

Parameters

cursorstring
Opaque cursor.

ServicePage

servicesService[]
Services in this page, in slug order.
nextCursorstring | undefined
Cursor for the next page, or undefined on the final page.

ServiceStatus

"enabled" routes requests, "disabled" retains the target without routing, "detached" has no target, and "unknown" represents an unrecognized backend value.

ServiceTarget

sandboxstring
Current name of the target sandbox.
portnumber
Sandbox port that receives requests.

ServiceError

A refused Service change or an unknown outcome. A missing Service throws ServiceNotFoundError, an unavailable slug throws ServiceAlreadyExistsError, and a missing target sandbox throws SandboxNotFoundError. Every MicrosandboxError from create, update, enable, disable, or remove exposes changed; it is "unknown" when the change may have been applied.
slugstring
Service slug.
reasonServiceErrorReason
Reason for the failure.
retryAfterMsnumber | null
Retry delay returned with the refusal, in milliseconds, or null.
changed”unchanged” | “unknown"
"unknown” means the change may have been applied; get and check the Service.
rawCodestring | null
Raw refusal code when reason is “other”.
rawStatusnumber | null
HTTP status when reason is “other”.
rawMessagestring | null
Raw refusal message when reason is “other”.

Reasons

”serviceQuotaExceeded”
The organization’s Service limit was reached. Remove a Service or request a higher limit.
”sandboxServiceLimitExceeded”
The target sandbox’s Service limit was reached. Remove or move a Service, or request a higher limit.
”serviceConflict”
Another change to the Service committed first. Get it, then retry.
”serviceDetached”
The Service is detached. Set a target.
”targetUnreachable”
The target sandbox cannot be reached right now. Retry later, after retryAfterMs when set.
”sandboxNotRunning”
The target sandbox is not running. Start it, then retry.
”serviceChangesPaused”
Service changes are paused. Retry later, after retryAfterMs when set.
”outcomeUnknown”
The change may have been applied. Get and check the Service before retrying.
”other”
A reason this SDK does not recognize; rawCode, rawStatus, and rawMessage preserve the refusal, and changed still reports the outcome.

ChangeState

”unchanged”
Nothing changed.
”unknown”
The change may have been applied. Get and check the Service before retrying.