Light APIv1.0.0

API / Reference / Expenses

Create upload URL

POST https://api.light.inc/v1/expenses/upload-url

Creates a pre-signed URL for uploading an expense receipt document

Requires a user credential with the reimbursement role; an API key is a service account, and with one the upload succeeds but no expense ever appears. The URL is valid for five minutes; PUT the bytes with the declared Content-Type and every entry of metadata as a request header (see Files).

Two modes. With shouldAutoCreateExpense omitted or true, Light creates an expense for the uploading user in status CREATED, runs OCR, and moves it to IN_DRAFT with the extracted fields; nothing returns its id, so find it with GET /v1/expenses?filter=userId:eq:<user>,status:in:CREATED|IN_DRAFT. With false, nothing happens until you call POST /v1/expenses with the returned key.

Authorization

Send one of these on every request. See Authentication for how to get credentials.

  • API key

    Basic authentication header of the form Basic <api_key>, where <api_key> is your api key.

  • Bearer token

Request body

application/json;charset=UTF-8

  • filename stringrequired

    Name of the file being uploaded; kept as the receipt's file name

  • contentType stringrequired

    MIME type of the file: application/pdf, image/jpeg, image/png, image/heic, image/heif or image/tiff

  • shouldAutoCreateExpense boolean

    When true (default), the uploaded receipt is converted to PDF, an expense is created automatically and its fields are extracted by OCR. When false, the receipt is only stored: no expense is created and nothing is parsed; the caller creates the expense itself from the returned key.

Response

  • uploadUrl string · url

  • key string

  • metadata object