API ReferenceapiaccountingPOST /v1/transactions

POST /v1/transactions

Service: accounting · operationId: (none)

Post an atomic multi-entry transaction (must sum to zero)

Required scopes

(no scope declared — review service config)

Required headers

  • idempotency-key

Request body

{
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "minLength": 1,
      "description": "Transaction type (payout, earning, etc.)"
    },
    "external_ref": {
      "type": [
        "string",
        "null"
      ],
      "description": "External reference (e.g. payment ID)"
    },
    "memo": {
      "type": [
        "string",
        "null"
      ],
      "description": "Transaction-level memo"
    },
    "entries": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "account_id": {
            "type": "string",
            "minLength": 1,
            "description": "Account to debit/credit"
          },
          "amount_cents": {
            "type": "integer",
            "description": "Amount in cents (positive or negative)"
          },
          "memo": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional memo for this entry"
          }
        },
        "required": [
          "account_id",
          "amount_cents"
        ]
      },
      "minItems": 2,
      "description": "Ledger entries (must sum to zero)"
    },
    "metadata": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {},
      "description": "Arbitrary metadata"
    }
  },
  "required": [
    "type",
    "entries"
  ]
}

Responses

201 Transaction posted successfully

{
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "type": {
      "type": "string"
    },
    "external_ref": {
      "type": [
        "string",
        "null"
      ]
    },
    "memo": {
      "type": [
        "string",
        "null"
      ]
    },
    "posted_at": {
      "type": "string",
      "format": "date-time"
    },
    "entries": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "amount_cents": {
            "type": "integer"
          },
          "memo": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "account_id",
          "amount_cents",
          "memo"
        ]
      }
    }
  },
  "required": [
    "id",
    "type",
    "external_ref",
    "memo",
    "posted_at",
    "entries"
  ]
}

400 Validation error (sum non-zero, missing fields, etc.)

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "error",
    "message"
  ]
}

409 Idempotency key conflict (same key, different body)

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "error",
    "message"
  ]
}

500 Internal server error

{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "error",
    "message"
  ]
}

Example

curl -X POST https://accounting.platform.loop.health/v1/transactions \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'