ReferenceReference by module

Settings API

Every Settings action (1) and data model (2): endpoints, scopes, input, preconditions, events and examples.

Settings for your business, this workspace and each module.

Module code settings · 1 actions · 2 data models · 1 events. A key or token never does more here than the person behind it can; row-level security applies exactly as in the app. Scopes: settings (everything), settings:read (read only) or settings:<capability>.

Resources

ResourceTableList and readPOSTPATCHDELETE
number_sequencesnumber_sequence/api/v1/number_sequences
settingssetting/api/v1/settings

Lists take limit (up to 200), cursor, order (e.g. -created_at), fields and q; every other query parameter is a column filter: ?status=paid, ?total[gte]=100, ?id[in]=a,b, ?x=null.

Actions

ActionNeedsWhat it does
settings.setsettings:manageChange a setting

settings.set

Change a setting — Writes one setting at the organization, workspace or module layer.

Needs settings:manage · changes data

POSThttps://app.getera.io/api/v1/settings/actions/set
API key or OAuth token · settings:manage
  • Canonical address: POST /api/v1/actions/settings.set

Input

FieldTypeRequiredNotes
layerstring (enum)yesLayer · Allowed values: organization, workspace, module
module_codestringModule · max 41
keystringyesKey · max 80
valuestringyesValue

Preconditions

The action is refused with 409 and one of these codes:

CodeRefused when
module_requiredA module setting has to say which module.
unknown_settingThat module does not declare that setting.
invalid_valueThe value does not match the setting’s type.

Events it publishes: settings.changed

What it writes: setting (upsert) — Writes the setting

curl -X POST https://app.getera.io/api/v1/settings/actions/set \
  -H "Authorization: Bearer $ERA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"layer":"organization","key":"Key","value":"Value"}'
Response
{
  "ok": true,
  "result": "…",
  "events": [
    "settings.changed"
  ]
}
import { createEra } from "@getera/sdk"

const era = createEra({ apiKey: process.env.ERA_API_KEY })
const res = await era.settings.set({
  layer: "organization",
  key: "Key",
  value: "Value"
})
era settings set \
  --layer "organization" \
  --key "Key" \
  --value "Value"
tools/call
{
  "name": "era__settings__set",
  "arguments": {
    "layer": "organization",
    "key": "Key",
    "value": "Value"
  }
}

Errors: 401 no or expired credential · 403 the credential does not hold settings:manage · 404 the record or module is outside what it may reach · 422 invalid input (problems[]) · 409 module_required, unknown_setting, invalid_value · 429 slow down

Data models

NumberSequence

Table number_sequence · Resource number_sequences

  • GET /api/v1/number_sequences
  • GET /api/v1/number_sequences/{id}
ColumnTypeNullableAllowed valuesReferences
idstring (uuid) · uuid
organization_idstring (uuid) · uuidorganization
workspace_idstring (uuid) · uuidworkspace
codestring · text
prefixstring · text
next_valuestring (int64) · int8
paddinginteger · int4

Primary key: id

Unique: workspace_id, code

Setting

Table setting · Resource settings

  • GET /api/v1/settings
  • GET /api/v1/settings/{id}
ColumnTypeNullableAllowed valuesReferences
idstring (uuid) · uuid
organization_idstring (uuid) · uuidorganization
workspace_idstring (uuid) · uuidyesworkspace
module_codestring · textyesmodule
keystring · text
valueobject · jsonb
updated_bystring (uuid) · uuidyesapp_user
updated_atstring (date-time) · timestamptz

Primary key: id

Checks:

  • CHECK (((module_code IS NULL) OR (workspace_id IS NOT NULL)))

Events

Workflows and webhooks react to these events.

EventWhat happensPayload
settings.changedA setting was changed.module_code, key