Update Statement

PATCH /api/v1/statements/:id

Updates the period and balance fields of a statement. Use this to manually set or correct statement period dates and opening/closing balances.

Path Parameters

ParameterTypeDescription
idstringStatement ID

Request Body

FieldTypeDescription
file_namestringDisplay name for the statement
period_startstringStatement period start date (YYYY-MM-DD)
period_endstringStatement period end date (YYYY-MM-DD)
opening_balanceintegerOpening balance (smallest currency unit)
closing_balanceintegerClosing balance (smallest currency unit)
reviewobjectReview status object (see below)

All fields are optional. Only include fields you want to update. Balance values should be integers in the smallest currency unit (e.g., paise for INR).

Review Object

FieldTypeDescription
is_donebooleanWhether review is complete
atstringISO 8601 timestamp of review
typestringReviewer type: ai or human
bystringUser ID if human reviewer, null if AI
work_record_idstringWorkRecord ID documenting the review

Example Request

curl -X PATCH "https://statements.finopsbricks.com/api/v1/statements/stmt123xyz" \
  -H "api-key: fob_stm_xxxxxxxxxxxx" \
  -H "api-secret: xxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "period_start": "2025-01-01",
    "period_end": "2025-01-31",
    "opening_balance": 5000050,
    "closing_balance": 4825075
  }'

Example: Rename Statement

curl -X PATCH "https://statements.finopsbricks.com/api/v1/statements/stmt123xyz" \
  -H "api-key: fob_stm_xxxxxxxxxxxx" \
  -H "api-secret: xxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "file_name": "HDFC Savings - January 2025.pdf"
  }'

Example: Update Period Only

curl -X PATCH "https://statements.finopsbricks.com/api/v1/statements/stmt123xyz" \
  -H "api-key: fob_stm_xxxxxxxxxxxx" \
  -H "api-secret: xxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "period_start": "2025-01-01",
    "period_end": "2025-01-31"
  }'

Response

{
  "data": {
    "id": "stmt123xyz",
    "file_name": "statement_jan_2025.pdf",
    "mime_type": "application/pdf",
    "file_type": "pdf",
    "file_size": "245760",
    "parser_type": "hdfc_savings__pdf",
    "step": "complete",
    "error": null,
    "account_id": "acc123",
    "account_name": "Main Account",
    "account_currency": "INR",
    "is_archived": false,
    "created_at": "2025-01-05T10:30:00.000Z",
    "period_start": "2025-01-01",
    "period_end": "2025-01-31",
    "opening_balance": 5000050,
    "closing_balance": 4825075,
    "data_source": {
      "period_start": "user_entered",
      "period_end": "user_entered",
      "opening_balance": "user_entered",
      "closing_balance": "user_entered"
    }
  }
}

Data Source Tracking

When you update a field, the data_source object tracks how the value was set:

Previous SourceAfter Update
null / unknownuser_entered
extracteduser_updated
computeduser_updated
user_entereduser_entered
user_updateduser_updated

This allows you to see whether a value was originally extracted from the statement or manually entered.

Validation Rules

Period Validation

If the statement has transactions, the period must contain all transaction dates:

  • period_start must be on or before the earliest transaction date
  • period_end must be on or after the latest transaction date

Example: If a statement has transactions from 2025-01-03 to 2025-01-28:

  • Valid: period_start: "2025-01-01", period_end: "2025-01-31"
  • Invalid: period_start: "2025-01-05" (after earliest transaction)
  • Invalid: period_end: "2025-01-25" (before latest transaction)

Validation Error Response

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "Invalid statement period",
    "details": [
      "period_start (2025-01-05) cannot be after earliest transaction (2025-01-03)"
    ]
  }
}

Errors

CodeDescription
400Invalid request body or validation error
401Invalid or missing API credentials
403API key lacks statements:edit permission
404Statement not found