API reference › Finance › Provider expenses

Bulk store or update provider expenses

POST /v1/finance/provider-expenses/bulk

Scope
finance:write
Roles
admin, service-provider, scheduler

Bulk store or update provider expenses. Template percentage rows: amount or expense as receipt (required). Non-percentage: quantity and/or expense/amount as line total. maximumReimbursementCap: receipt cap for percentage (422); line-total cap for other bases. Receipt patch: omit document to keep file. Sync: submitted list is full desired set per group.

Parameters

None of its own.

Every call also sends Authorization and X-Tenant-ID; see Getting started.

Request body required

FieldTypeDescription
affectFinancialsboolean or null

Required when the change moves money on a work item whose linked finance document is Sent or Approved; without it the call returns 422 FINANCIAL_CONSENT_REQUIRED. true applies the change to those documents; false saves it and marks them out of sync.

providerExpenses requiredarray of object
providerExpenses[].entityIdstring or null

Work item the expenses belong to (ASG-* or SFT-*). Defaults to the work item being saved.

Example ASG-SA2IVL.

providerExpenses[].providerId requiredstring

Example SPR-H6OUI3.

providerExpenses[].expensesarray of object
providerExpenses[].expenses[].idinteger or null

Existing expense id to update; omit to create.

Example 42.

providerExpenses[].expenses[].name requiredstring

Example Parking.

providerExpenses[].expenses[].amountnumber or null

min 0.01. Example 12.5.

providerExpenses[].expenses[].expensenumber or null

Unit amount, multiplied by quantity.

min 0.01. Example 12.5.

providerExpenses[].expenses[].quantitynumber or null

min 0.01. Example 1.

providerExpenses[].expenses[].billTostring or null

One of: organization, client. Example organization.

providerExpenses[].expenses[].documentstring (binary) or null

Receipt: pdf, jpg, jpeg or png, max 2 MB.

providerExpenses[].expenses[].isDefaultboolean or null
providerExpenses[].expenses[].reimbursement_basicstring or null

Reimbursement basis of a freeform custom expense.

One of: per_unit, per_day, flat_amount, percentage.

providerExpenses[].expenses[].expenseTypestring or null

One of: travel, lodging, meals, supplies, miscellaneous.

providerExpenses[].expenses[].ratenumber or null

Required when reimbursement_basic is percentage.

min 0.

providerExpenses[].expenses[].sourceReimbursableExpenseobject

Catalog category a custom line is seeded from.

providerExpenses[].expenses[].sourceReimbursableExpense.idinteger or string

Example 1.

providerExpenses[].expenses[].sourceReimbursableExpense.labelstring or null

Example Example.

Example

JSON
{
  "affectFinancials": true,
  "providerExpenses": [
    {
      "entityId": "ASG-SA2IVL",
      "providerId": "SPR-H6OUI3",
      "expenses": [
        {
          "id": 42,
          "name": "Parking",
          "amount": 12.5,
          "expense": 12.5,
          "quantity": 1,
          "billTo": "organization",
          "document": "string",
          "isDefault": true,
          "reimbursement_basic": "per_unit",
          "expenseType": "travel",
          "rate": 0,
          "sourceReimbursableExpense": {
            "id": 1,
            "label": "Example"
          }
        }
      ]
    }
  ]
}

Example request

Shell
curl -X POST "https://api.fetchfido.ai/v1/finance/provider-expenses/bulk" \
  -H "Authorization: Bearer $FIDO_API_KEY" \
  -H "X-Tenant-ID: $FIDO_TENANT_ID" \
  -H "Content-Type: application/json" \
  -d '{"affectFinancials":true,"providerExpenses":[{"entityId":"ASG-SA2IVL","providerId":"SPR-H6OUI3","expenses":[{"id":42,"name":"Parking","amount":12.5,"expense":12.5,"quantity":1,"billTo":"organization","document":"string","isDefault":true,"reimbursement_basic":"per_unit","expenseType":"travel","rate":0,"sourceReimbursableExpense":{"id":1,"label":"Example"}}]}]}'

Try it

Responses

200 Expenses submitted for review

Expenses submitted for review.

JSON
{
  "success": true,
  "message": "Expenses submitted for review.",
  "data": [
    {
      "entityId": "ASG-12345",
      "providerId": "USR-67890",
      "expenses": [
        {
          "id": 123,
          "name": "Parking",
          "amount": 25.5,
          "isDefault": true
        }
      ]
    }
  ]
}
Response fields (10)
FieldTypeDescription
successboolean

Example true.

messagestring

Example Expenses submitted for review..

dataarray of object
data[].entityIdstring

Example ASG-12345.

data[].providerIdstring

Example USR-67890.

data[].expensesarray of object
data[].expenses[].idinteger or null

Example 123.

data[].expenses[].namestring

Example Parking.

data[].expenses[].amountnumber (float)

Example 25.5.

data[].expenses[].isDefaultboolean or null

Example true.

401 Not signed in

Unauthorized

JSON
{
  "success": false,
  "message": "Invalid API key. Org and user tier keys must send an X-Tenant-ID header naming the organization the key was issued for.",
  "errors": null,
  "code": "API_KEY_MISSING"
}
Response fields (4)
FieldTypeDescription
successboolean

Example false.

messagestring

Example Invalid API key. Org and user tier keys must send an X-Tenant-ID header naming the organization the key was issued for..

errorsany or null

Null on this status.

codestring

Machine-readable reason, for branching on in client code.

One of: API_KEY_MISSING, API_KEY_INVALID, API_KEY_EXPIRED. Example API_KEY_MISSING.

403 Not allowed

Forbidden

JSON
{
  "success": false,
  "message": "You don't have permission to access this endpoint. This API key is missing the 'finance:write' scope.",
  "errors": null,
  "code": ""
}
Response fields (4)
FieldTypeDescription
successboolean

Example false.

messagestring

Example You don't have permission to access this endpoint. This API key is missing the 'finance:write' scope..

errorsany or null

Null on this status.

codestring

Always empty on this status.

Example .

422 Validation failed

Validation error

JSON
{
  "status": "error",
  "message": "Unable to save. Please check the highlighted fields",
  "errors": {
    "name": [
      "Please enter a name."
    ],
    "email": [
      "The email has already been taken."
    ]
  }
}
429 Too many requests

Rate limit exceeded. See Retry-After.

JSON
{
  "success": false,
  "message": "You've exceeded this API key's rate limit of 120 requests per minute. Try again in 37 seconds.",
  "errors": null,
  "code": "RATE_LIMITED"
}
Response fields (4)
FieldTypeDescription
successboolean

Example false.

messagestring

Example You've exceeded this API key's rate limit of 120 requests per minute. Try again in 37 seconds..

errorsany or null

Null on this status.

codestring

Machine-readable reason, for branching on in client code.

One of: RATE_LIMITED. Example RATE_LIMITED.

500 Server error

Internal Server Error

JSON
{
  "success": false,
  "message": "An unexpected error occurred — please try again.",
  "errors": null,
  "code": ""
}
Response fields (4)
FieldTypeDescription
successboolean

Example false.

messagestring

Example An unexpected error occurred — please try again..

errorsstring or null

Null in production. The exception message only when the application runs with debug on, so nothing is leaked to an integrator.

codestring

Always empty: the server-error response carries no error code.

Example .