Skip to content

Thing routes: relate, resolve, restore

The Thing Verbs relate, resolve, restore as api.sb routes, with inputs, result, refusals and an example.

Reference for Thing, one group of Thing routes.

Thing.relate

Relate links two Things by a Relationship their Nouns declare, readable from both ends at once. Verb page.

Text
POST /{namespace}/things/{thing}/relate

Path: thing. Body, as JSON: the other inputs. Emits Thing.related.

Inputs

InputTypeRequiredDescription
thingThingrequiredThe source Thing.
predicatestringrequiredThe Relationship as read from the source, such as places.
toThingrequiredThe target Thing.

Returns

OutputTypeRequiredDescription
relationshipRelationshiprequiredThe Relationship, with its provenance.
thingThingrequiredThe Thing the Relationship starts from.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.
A predicate that neither Noun declaresrefusedClear what the check names, then call it again.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/things/thing_8ds0r9vvRl/relate \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"predicate":"Example predicate","to":"thing_8ds0r9vvRl"}'
JSON
{
  "api": "https://api.sb/leaseline.app",
  "relationship": {
    "$id": "https://api.sb/leaseline.app/relationships/relationship_iUVcHztTJh",
    "$type": "Relationship",
    "predicate": "Example predicate",
    "inverse": "Example inverse"
  },
  "thing": {
    "$id": "https://api.sb/leaseline.app/things/thing_8ds0r9vvRl",
    "$type": "Thing",
    "id": "Example id",
    "type": [
      "noun_v0akLUrXCN"
    ]
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Thing.relate",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}

Thing.resolve

Resolve finds the one Thing of a Noun that matches given properties, or creates it, and says which it did. Verb page.

Text
POST /{namespace}/things/resolve

Body, as JSON: the inputs. Emits Thing.resolved.

Inputs

InputTypeRequiredDescription
nounNounrequiredThe Noun to resolve.
matchjsonrequiredThe properties that identify the Thing, such as an email address.
setjsonProperties to write on the found or created Thing.

Returns

OutputTypeRequiredDescription
thingThingThe Thing found or created; empty when held.
decisionstringrequiredWhat happened: found, created, or held when two or more Things match.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/things/resolve \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"noun":"noun_v0akLUrXCN","match":{}}'
JSON
{
  "api": "https://api.sb/leaseline.app",
  "thing": {
    "$id": "https://api.sb/leaseline.app/things/thing_8ds0r9vvRl",
    "$type": "Thing",
    "id": "Example id",
    "type": [
      "noun_v0akLUrXCN"
    ]
  },
  "decision": "found",
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Thing.resolve",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}

Thing.restore

Restore brings back a deleted Thing, or one an undone Action removed, with its history and Relationships intact. Verb page.

Text
POST /{namespace}/things/{thing}/restore

Path: thing. Emits Thing.restored.

Inputs

InputTypeRequiredDescription
thingThingrequiredThe deleted Thing.

Returns

OutputTypeRequiredDescription
thingThingrequiredThe Thing, back in every list and query it left.

Refuses when

CheckErrorFixThen call
The key is valid, but its scopes do not allow this operation.forbiddenUse a key whose scopes cover the operation, or ask an owner of the namespace to grant them.None.
The Thing is not deletedrefusedClear what the check names, then call it again.None.

Example

Terminal
curl -X POST https://api.sb/leaseline.app/things/thing_8ds0r9vvRl/restore \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
JSON
{
  "api": "https://api.sb/leaseline.app",
  "thing": {
    "$id": "https://api.sb/leaseline.app/things/thing_8ds0r9vvRl",
    "$type": "Thing",
    "id": "Example id",
    "type": [
      "noun_v0akLUrXCN"
    ]
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Thing.restore",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}