API ReferenceapicashPOST /v1/cash/spend

POST /v1/cash/spend

Service: cash · operationId: (none)

Spend cash from user account (balance must cover the amount)

Required scopes

(no scope declared — review service config)

Required headers

  • idempotency-key

Request body

{
  "type": "object",
  "properties": {
    "user_id": {
      "type": "string",
      "minLength": 1,
      "description": "User spending cash"
    },
    "brand_id": {
      "type": "string",
      "minLength": 1,
      "description": "Brand scope"
    },
    "amount_cents": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "description": "Amount in cents to spend"
    },
    "reason": {
      "type": "string",
      "minLength": 1,
      "description": "Spend reason (e.g. purchase, redemption)"
    },
    "memo": {
      "type": "string",
      "description": "Optional memo"
    }
  },
  "required": [
    "user_id",
    "brand_id",
    "amount_cents",
    "reason"
  ]
}

Responses

201 Cash spent successfully

{
  "type": "object",
  "properties": {
    "entry_id": {
      "type": "string"
    },
    "account_id": {
      "type": "string"
    },
    "amount_cents": {
      "type": "integer"
    },
    "balance_cents": {
      "type": "integer"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "entry_id",
    "account_id",
    "amount_cents",
    "balance_cents",
    "created_at"
  ]
}

400 Validation error

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

404 Account not found

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

409 Insufficient balance

{
  "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://cash.platform.loop.health/v1/cash/spend \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ ... }'