Skip to content

Concepts

Simulations

A simulation is a hosted, stateful copy of an API's behaviour: records in collections, a plan that changes them over time, and rules that bend individual responses.

Lifecycle

When you create a simulation, Slurry parses the spec, works out the data model, generates seed data and starts serving. A model is used for the analysis and seed data (this uses your plan's AI allowance); everything after that is deterministic engine work that never uses AI.

StatusMeaning
queuedWaiting for a worker.
analysingReading the spec and building the data model.
seedingGenerating and storing records.
runningServing requests and running the behaviour plan.
pausedRequests return 503 and the schedule stops. Data is kept.
failedSet-up could not complete. The status detail says why.
pending_reviewWaiting for content review before going live.
suspendedStopped by abuse monitoring or an administrator, pending review.

Collections

The data model groups records into collections - tasks, projects, users - each with an id style, a schema, field hints for realistic values and, where the API has one, a status field with its states and allowed transitions. Operations in the spec are bound to collections as list, get, create, update, delete or action.

  • A POST to a create operation inserts a record; later lists and gets include it.
  • Request bodies are read as JSON or as forms. Form keys with brackets nest as Stripe sends them: metadata[order]=42 is { "metadata": { "order": "42" } }, expand[]=a and items[0][price]=p are arrays. Keys deeper than 5 levels, indexes over 999, __proto__, constructor or prototype segments, clashes and pairs after the first 1,000 stay flat.
  • Nested paths such as /projects/{project_gid}/tasks are scoped to their parent.
  • References between collections point at records that exist, so joins in your code behave.
  • A collection given volume 0 at creation ({ "volume": { "Invoices": 0 } }) is empty: no generated records, no history laid out by the ledger or world, and no records added by the scheduled rules (the live chat and issue refills of Teams and Jira can still add a few). Your seedRecords still load, and a ledger keeps its one organisation.
  • Operations that do not map to data return a schema-valid static response.

Vendor behaviour

Seeded records are generated, so they vary. What a client does follows the vendor's own rules, so the same calls give the same result every run.

Stripe PaymentIntents

/v1/payment_intents behaves as Stripe test mode. Failures come from Stripe's test payment methods, or from your rules and faults, never from chance.

  • A create with confirm=true and a payment method ends succeeded, with amount_received equal to amount, or requires_capture with capture_method=manual. Without confirm it is requires_confirmation, or requires_payment_method when none was given.
  • /confirm, /cancel and /capture move the intent as Stripe does. Confirming an intent that is not waiting for it answers 400 payment_intent_unexpected_state.
  • pm_card_chargeDeclined and its variants (InsufficientFunds, ExpiredCard, IncorrectCvc and the rest) answer 402 card_declined with the matching decline_code. The intent is kept as requires_payment_method.
  • pm_card_authenticationRequired gives requires_action on session. With off_session=true it answers 402 authentication_required.
  • Settings you leave out take Stripe's defaults (capture_method is automatic_async), never a generated value. Request-only parameters such as confirm and off_session are not stored on the intent.

Xero invoices and payments

In a Xero simulation, an invoice or bill you create is what you sent, with the sums Xero works out. Nothing on it is generated.

  • Each line's LineAmount is Quantity x UnitAmount, less any DiscountRate (Quantity is kept to 4 decimal places and DiscountRate to 2, as in Xero; a line sent with a LineAmount and no UnitAmount has its unit price worked back from it). Its TaxAmount comes from its TaxType: Xero UK's rates for the system types (OUTPUT2 and INPUT2 20%, RROUTPUT and RRINPUT 5%, zero-rated, exempt and NONE 0%), the simulation's TaxRates for any other type, and 0 for a type neither names.
  • LineAmountTypes is Exclusive unless you send Inclusive or NoTax. SubTotal, TotalTax and Total add up from the lines, and AmountDue is the Total. A bill of one line at 1,550 with INPUT2 totals 1,860.00 every time.
  • A new invoice has AmountPaid 0, no payments, credit notes or attachments, Status DRAFT unless you send SUBMITTED or AUTHORISED, and the organisation's base currency unless you send one. A sales invoice sent with no number takes the next INV- number.
  • PUT or POST /Payments, with { "Payments": [{ "Invoice": { "InvoiceID": ... }, "Account": { "Code": ... }, "Date": ..., "Amount": ... }] } or a single payment, records each payment as AUTHORISED, with its account found by AccountID or Code. The invoice's AmountPaid rises and AmountDue falls; at nothing due it is PAID, with FullyPaidOnDate the payment date.
  • A payment to an invoice that is not found or not AUTHORISED, with no amount or one above AmountDue, answers 400 ValidationException with Xero's messages in Elements[].ValidationErrors. Up to 50 payments a call, all or nothing: one refused and none is recorded. Payment calls to one simulation are served one at a time; past 50 waiting, the next answers 429 with Retry-After: 1 and X-Rate-Limit-Problem: concurrent, as Xero's concurrent limit does.

The behaviour plan

The behaviour plan is what makes a simulation live. It is a declarative list of rules; each rule runs every everySeconds (never faster than your plan allows) and applies its steps. It is written once, by a model, when the simulation is created, then executed by the engine with no model calls per tick. You can read and replace it at any time.

StepWhat it does
transitionMoves a fraction of matching records from one state to another, optionally weighted.
createCreates between min and max new records, with optional field overrides.
updateIncrements, decrements, touches or regenerates a field on a fraction of records.
deleteDeletes a fraction of records, optionally filtered.
PUT /v1/simulations/{id}/behaviour
{
  "rules": [
    {
      "id": "progress-tasks",
      "name": "Tasks move through the board",
      "everySeconds": 900,
      "enabled": true,
      "steps": [
        {
          "kind": "transition",
          "collection": "tasks",
          "field": "status",
          "from": ["todo", "in_progress"],
          "to": ["in_progress", "in_review", "done"],
          "weights": [0.5, 0.3, 0.2],
          "fraction": 0.1,
          "maxPerTick": 25,
          "event": "task.updated"
        },
        {
          "kind": "create",
          "collection": "tasks",
          "count": { "min": 0, "max": 3 },
          "event": "task.created"
        }
      ]
    }
  ]
}
Limits: up to 20 rules, 10 steps per rule and 200 changes per tick. The minimum interval is 60 seconds, raised to your plan's schedule floor (15 minutes on Starter, 5 on Team, 1 on Scale).
A one-way transition - a from list that never includes a destination, such as confirmed to cancelled - holds at most half the collection in its destination states, so a small hourly fraction cannot empty a world over a few days. New records that copy an existing one never copy a record a one-way transition has already moved.

Fast-forward

POST /v1/simulations/{id}/fast-forward with { "hours": 168 } runs each enabled rule as many times as it would have fired in that window (capped at 200 ticks per rule), then persists the net changes and queues webhooks. The maximum is 720 hours - 30 days - per call. The response tells you how many records changed.

Reset

POST /v1/simulations/{id}/reset regenerates the records from the original seed. Generation is seeded deterministically from the simulation, so a reset puts back the same records every time. Rules, behaviour edits and webhooks are kept. It runs in the background: the status goes to queued and back to running. To save and restore any other state, use snapshots.

Pause and resume

Pause a simulation to stop both traffic and schedule without losing data: POST /v1/simulations/{id}/pause and /resume.

Addresses

Each simulation is served at https://<slug>.slurry.io, and also in path mode at https://api.slurry.io/s/<slug>/.... Request and response headers, including Slurry-Session and Slurry-Force, are listed under Worlds.