Skip to content

Make an older version current again

POST
/orgs/{org}/libraries/{namespace}/versions/{number}/restore
curl --request POST \
--url https://api.sloose.com/orgs/org_9f3c/libraries/acme/versions/2/restore \
--header 'Authorization: Bearer <token>' \
--header 'If-Match: "7"'

Publishes that version’s source and manifest again, as the next version — the history stays a straight line, and it says which version was brought back. It is checked as any publish is, so a version that no longer loads is refused. Restoring the version that is already current publishes nothing. The helper_libraries plan feature, as publishing is.

org
required

The org id the session was issued for. A token for one org can never read another.

string
Example
org_9f3c

The org id the session was issued for. A token for one org can never read another.

namespace
required

The library namespace, as it appears in expressions.

string
Example
acme

The library namespace, as it appears in expressions.

number
required

Which publish: 1 for v1.

string
Example
2

Which publish: 1 for v1.

If-Match

The registryVersion this change was made against, as "7" or 7 — a weak tag (W/"7") is refused, since If-Match uses strong comparison. Sent, the write is refused with 409 (code: REGISTRY_CONFLICT, the current version in the body) when the org has moved since, and otherwise answers the version it made: one past the version sent for a write made in one transaction, or the version sent itself for a request that asks for no change (an empty PATCH /config/writing), since it makes none. A bundle (POST /config/bundle) is several transactions and only its first waits on this version: it answers the version its own bumps took the org to, and none — nor an etag — when another write landed between them; one landing after them, while its templates are saved, withholds the etag alone. Omitted, there is no condition, and * is no condition either — and a write with no condition answers no registryVersion (nor, from a bundle, an etag), since nothing says which version it was made from. A value that is neither is 400 (code: BAD_IF_MATCH) rather than ignored — a precondition silently dropped looks like conflict detection and is not.

string
Example
"7"

The registryVersion this change was made against, as "7" or 7 — a weak tag (W/"7") is refused, since If-Match uses strong comparison. Sent, the write is refused with 409 (code: REGISTRY_CONFLICT, the current version in the body) when the org has moved since, and otherwise answers the version it made: one past the version sent for a write made in one transaction, or the version sent itself for a request that asks for no change (an empty PATCH /config/writing), since it makes none. A bundle (POST /config/bundle) is several transactions and only its first waits on this version: it answers the version its own bumps took the org to, and none — nor an etag — when another write landed between them; one landing after them, while its templates are saved, withholds the etag alone. Omitted, there is no condition, and * is no condition either — and a write with no condition answers no registryVersion (nor, from a bundle, an etag), since nothing says which version it was made from. A value that is neither is 400 (code: BAD_IF_MATCH) rather than ignored — a precondition silently dropped looks like conflict detection and is not.

The library as it now stands.

Media typeapplication/json
object
library
required
object
namespace
required
string
libraryId
required

The library’s own id. A name removed and published again is another library under a new id (#1040), so a page that changes who publishes it names this (PUT …/management), and an import’s kept version names it too (LibraryPin.library).

string
version
required

The manifest’s own semver: the author’s label, not which publish this is.

string
versionNumber
required

Which publish is current: 3 for v3 (…/versions). 0 for a library stored before versions were kept.

number
scope
required
string
Allowed values: global org
manifest
required
object
key
additional properties
source

The module as written, when the route answers it (?source=true on the list).

string
managedBy
required

sdk when the org’s configuration repository publishes it: its page is read only, and a person publishing, restoring or removing it is refused (409 LIBRARY_MANAGED) until it is taken over (PUT …/management), while an API token, which publishes as the repository, may. Null when people publish it on its page, where a push leaves it alone and says so and an API token is refused. A library a push or a token makes is the repository’s.

string | null
Allowed values: sdk
updatedAt
required
string
published
required
boolean
registryVersion

The version the org is at after this write, to send as the next write’s If-Match: one past the version you sent in If-Match for a write made in one transaction (a bundle, several, answers the version its own bumps took the org to, or none when another write landed between them), or that version itself for a request that asks for no change (an empty PATCH /config/writing, which writes nothing and makes no version; sending the value the org already has still writes, and moves it). Only a write sent with a version in If-Match answers one. Without (no header, or *), the write lands on whatever version the org is at, and nothing on the server knows which version your picture of the configuration was built from: another administrator’s change may be inside the number, and sent back as If-Match it would let your next write overwrite that change unseen. So it is left out. To write again, read the configuration first (its GET answers the version), or send If-Match.

number
Example
{
"library": {
"scope": "global",
"managedBy": "sdk"
}
}

No bearer, or one that is expired, revoked or no longer resolves to a member.

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Examplegenerated
{
"error": "example",
"code": "example"
}

Not an administrator, or this plan cannot publish helper libraries (code: FEATURE_HELPER_LIBRARIES).

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Examplegenerated
{
"error": "example",
"code": "example"
}

No such library or version, or it is not visible to this session.

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Examplegenerated
{
"error": "example",
"code": "example"
}

The org’s configuration has changed since the version in If-Match (REGISTRY_CONFLICT, the current one in the body); or the library is published by the other publisher (LIBRARY_MANAGED, which says who in managedBy): a person is refused one the configuration repository publishes — restore it there, or take it over first — and an API token, which publishes as the repository, one taken over in the browser.

Media typeapplication/json
Any of:
object
error
required
string
code
required
string
Allowed values: REGISTRY_CONFLICT
registryVersion
required
number
key
additional properties
Example
{
"code": "REGISTRY_CONFLICT"
}

The manifest’s namespace does not match the path, it declares global scope, it names core or one of Sloose’s own helpers (helpers.trim, helpers.date…), which a library by that name would replace, or the library does not load — error says what stopped it, with the line and column where there is one.

Media typeapplication/json
object
error
required
string
code
required
string
Allowed values: NAMESPACE_MISMATCH GLOBAL_LIBRARY RESERVED_NAMESPACE LIBRARY_DOES_NOT_LOAD
key
additional properties
Example
{
"code": "NAMESPACE_MISMATCH"
}

Libraries cannot be checked just now: the sandbox did not answer (code: SANDBOX_UNAVAILABLE).

Media typeapplication/json

The error envelope every non-2xx answer uses.

object
error
required

Human-readable explanation.

string
code

Machine-readable reason. Absent on a few legacy 400s.

string
key
additional properties
Examplegenerated
{
"error": "example",
"code": "example"
}

Report a problem with this page