orders

Execute an order

Changed on

This endpoint carries out an order on demand, without waiting for its execute_at schedule. It runs synchronously, so the response carries the resulting status and, when the execution fails, the reason it failed. An execute_in_lago order applies the quoted deal, creating the subscriptions, coupons, wallets or one-off invoice it describes; an order_only order is simply marked as executed. What the execution produced is listed in execution_record. Executing is idempotent: an order that has already been executed is returned untouched. An order whose previous execution failed is executed again, and a 422 is returned when the order carries no execution mode and none is provided in the body. Restating an execution_mode that differs from the one stored on the order updates it first, which only succeeds while the order is still created: a failed order can be retried, but not switched to another mode. That update also re-validates the order's own execute_at against the day the quoted deal stops being executable, so a 422 is possible even though no date was sent. An order carrying no execute_at is not bounded that way, and a deal whose term has passed then only fails when the execution runs. A 404 is not limited to an unknown order: when the execution cannot find a catalog record the quote pinned, such as a deleted plan, charge, coupon or the subscription being amended, the missing resource is reported as a 404 and the order is left failed. Concurrency is reported two ways. A mode change losing the race on the quote comes back as a 422 validation error, while the execution itself losing it comes back as a 422 carrying a lock code, because a scheduled execution relies on that error to be retried. This is a premium feature.

post/orders/{lago_id}/execute

Request

Request body

Example request

{
  "order": {
    "execution_mode": "execute_in_lago"
  }
}

Response

Order executed

Example response

{
  "order": {
    "lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
    "number": "OR-2026-0001",
    "status": "created",
    "order_type": "subscription_creation",
    "execution_mode": "execute_in_lago",
    "currency": "USD",
    "executed_at": "2026-07-01T00:00:00Z",
    "execution_record": {
      "executed_at": "2026-07-01T00:00:00Z",
      "execution_mode": "execute_in_lago",
      "invoice_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
      "subscription_ids": [
        "1a901a90-1a90-1a90-1a90-1a901a901a90"
      ],
      "terminated_subscription_ids": [
        "1a901a90-1a90-1a90-1a90-1a901a901a90"
      ],
      "applied_coupon_ids": [
        "1a901a90-1a90-1a90-1a90-1a901a901a90"
      ],
      "wallet_ids": [
        "1a901a90-1a90-1a90-1a90-1a901a901a90"
      ],
      "errors": [
        "plan_not_found"
      ]
    },
    "lago_organization_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
    "lago_customer_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
    "lago_order_form_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
    "created_at": "2026-04-29T08:59:51Z",
    "updated_at": "2026-04-29T08:59:51Z",
    "billing_snapshot": {
      "addOns": [
        {
          "id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
          "localId": "b5c1e2a4-4e1e-4a7f-9f0e-9c1a0c7e1f2b",
          "type": "add_on",
          "payload": {
            "code": "setup_fee",
            "units": 1,
            "unitAmountCents": 10000,
            "totalAmountCents": 10000,
            "fromDatetime": "2026-01-01T00:00:00Z",
            "toDatetime": "2026-12-31T23:59:59Z"
          },
          "overrides": {
            "description": "Onboarding package, discounted for the first year",
            "units": 2,
            "unitAmountCents": 8000,
            "totalAmountCents": 16000,
            "invoiceDisplayName": "Onboarding",
            "fromDatetime": "2026-01-01T00:00:00Z",
            "toDatetime": "2026-12-31T23:59:59Z"
          }
        }
      ],
      "plans": [
        {
          "id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
          "localId": "b5c1e2a4-4e1e-4a7f-9f0e-9c1a0c7e1f2b",
          "type": "plan",
          "payload": {
            "code": "premium_plan",
            "subscriptionExternalId": "sub_1234567890",
            "subscriptionName": "Premium plan - Acme Corp",
            "billingTime": "calendar",
            "startDate": "2026-01-01T00:00:00Z",
            "endDate": "2027-01-01T00:00:00Z",
            "paymentMethodId": "1a901a90-1a90-1a90-1a90-1a901a901a90",
            "charges": [
              {
                "id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
                "billableMetric": {
                  "code": "api_calls"
                },
                "chargeModel": "standard"
              }
            ],
            "fixedCharges": [
              {
                "id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
                "addOn": {
                  "code": "seats"
                },
                "chargeModel": "standard"
              }
            ]
          },
          "overrides": {
            "amountCents": 50000,
            "amountCurrency": "USD",
            "invoiceDisplayName": "Premium",
            "name": "Premium plan - Acme Corp",
            "description": "Negotiated premium plan",
            "trialPeriod": 30,
            "minimumCommitment": {
              "amountCents": 100000,
              "invoiceDisplayName": "Annual commitment"
            },
            "usageThresholds": [
              {
                "amountCents": 100000,
                "thresholdDisplayName": "First 1,000 EUR of usage"
              }
            ],
            "charges": [
              {
                "billableMetricCode": "api_calls",
                "chargeModel": "standard",
                "properties": {
                  "amount": "0.02"
                },
                "minAmountCents": 10000,
                "invoiceDisplayName": "API calls"
              }
            ],
            "fixedCharges": [
              {
                "addOnCode": "seats",
                "units": "10",
                "properties": {
                  "amount": "5"
                },
                "invoiceDisplayName": "Seats"
              }
            ]
          }
        }
      ],
      "coupons": [
        {
          "id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
          "localId": "b5c1e2a4-4e1e-4a7f-9f0e-9c1a0c7e1f2b",
          "type": "coupon",
          "payload": {
            "code": "welcome_offer",
            "type": "fixed_amount",
            "amountCents": 10000,
            "currency": "USD",
            "percentageRate": 10.5,
            "frequency": "once",
            "frequencyDuration": 3
          },
          "overrides": {
            "amountCents": 15000,
            "amountCurrency": "USD",
            "percentageRate": 15,
            "frequency": "recurring",
            "frequencyDuration": 6
          }
        }
      ],
      "walletCredits": [
        {
          "localId": "b5c1e2a4-4e1e-4a7f-9f0e-9c1a0c7e1f2b",
          "type": "wallet_credit",
          "payload": {
            "paidCredits": "100.0",
            "grantedCredits": "20.0",
            "rateAmount": "1.0",
            "currency": "USD",
            "expirationAt": "2027-01-01T00:00:00Z",
            "appliesTo": {
              "feeTypes": [
                "charge"
              ],
              "billableMetricCodes": [
                "api_calls"
              ]
            },
            "recurringTransactionRules": [
              {
                "trigger": "interval",
                "interval": "monthly",
                "thresholdCredits": "10.0",
                "method": "fixed",
                "targetOngoingBalance": "100.0",
                "paidCredits": "100.0",
                "grantedCredits": "20.0",
                "startedAt": "2026-01-01T00:00:00Z",
                "expirationAt": "2027-01-01T00:00:00Z",
                "transactionName": "Monthly top-up"
              }
            ]
          }
        }
      ]
    }
  }
}

Changes