> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.monite.com/v-2024-05-25/api/receipts/post-receipts-id-attach-file/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.monite.com/_mcp/server. # Attach a file to a receipt POST https://api.sandbox.monite.com/v1/receipts/{receipt_id}/attach_file Content-Type: multipart/form-data Attach a file to a receipt without an existing attachment. Reference: https://docs.monite.com/api/receipts/post-receipts-id-attach-file ## Authentication - `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer `, where token is your auth token. ## Servers - `https://api.sandbox.monite.com/v1` (sandbox, default) - `https://api.monite.com/v1` (eu_production) - `https://us.api.monite.com/v1` (na_production) ## Request ### Path parameters - `receipt_id` (string, required) ### Headers - `x-monite-version` (string, required) - `x-monite-entity-id` (string, required) — The ID of the entity that owns the requested resource. ### Body (multipart/form-data) This endpoint expects a multipart form containing a file. - `file` (file, required) ## Response ### 200 Successful Response - `id` (string, required) — Unique receipt ID. - `created_at` (datetime, required) — Creation timestamp. - `updated_at` (datetime, required) — Update timestamp. - `origin` (enum, required) — Specifies how this receipt was created in Monite. - Allowed values: `upload`, `email` - `created_by_entity_user_id` (string, optional) — Entity user who created. - `currency` (enum, optional) — Currency code. - Allowed values: `AED`, `AFN`, `ALL`, `AMD`, `ANG`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BGN`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHF`, `CLP`, `CNY`, `COP`, `CRC`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MUR`, `MVR`, `MWK`, `MXN`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `SVC`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `UYU`, `UZS`, `VND`, `VUV`, `WST`, `XAF`, `XCD`, `XOF`, `XPF`, `YER`, `ZAR`, `ZMW` - `currency_exchange` (map from string to any, optional) — Currency exchange details. - `description` (string, optional) — Short transaction description. - `document_id` (string, optional) — Receipt number. - `file_id` (string, optional) — The id of the receipt file stored in the file saver. - `file_url` (string, optional) — The URL of the receipt file stored in the file saver. - `issued_at` (datetime, optional) — Date when the receipt was issued. - `merchant_location` (string, optional) — Merchant location. - `merchant_name` (string, optional) — Merchant name. - `ocr_request_id` (string, optional) — OCR request id. - `ocr_status` (string, optional) — OCR status. - `partner_metadata` (map from string to any, optional) — Partner metadata. - `sender` (string, optional) — The email address from which the invoice was sent to the entity. - `source_of_data` (enum, optional) — Source of data. - Allowed values: `ocr`, `user_specified` - `total_amount` (integer, optional) — Total amount in minor units. - `transaction_id` (string, optional) — Transaction ID. ## Errors ### 400 Post Receipts ID Attach File Request Bad Request Error Bad Request - `error` (ErrorSchema2, required) ### 401 Post Receipts ID Attach File Request Unauthorized Error The `Authorization` header is missing or contains an invalid or expired access token. See [Authentication](https://docs.monite.com/api/concepts/authentication) to learn how to authenticate API calls. - `any` ### 403 Post Receipts ID Attach File Request Forbidden Error The specified access token does not have permissions to perform this operation. - `error` (ErrorSchema2, required) ### 404 Post Receipts ID Attach File Request Not Found Error Not Found - `error` (ErrorSchema2, required) ### 409 Post Receipts ID Attach File Request Conflict Error Conflict - `error` (ErrorSchema2, required) ### 422 Post Receipts ID Attach File Request Unprocessable Entity Error Validation Error - `detail` (list of ValidationError, optional) ### 429 Post Receipts ID Attach File Request Too Many Requests Error API rate limit has been exceeded. Check the response headers for the rate limit information. - `any` ## Types ### ErrorSchema2 - `message` (string, required) ### ValidationError - `loc` (list of ValidationErrorLocItem, required) - `msg` (string, required) - `type` (string, required) ### ValidationErrorLocItem ## Examples **Request** ```json { "file": ">" } ``` **Response** ```json { "id": "id", "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z", "origin": "upload", "created_by_entity_user_id": "created_by_entity_user_id", "currency": "AED", "currency_exchange": { "key": "value" }, "description": "Payment for lunch with clients", "document_id": "document_id", "file_id": "123e4567-e89b-12d3-a456-426614174000", "file_url": "file_url", "issued_at": "2024-01-15T09:30:00Z", "merchant_location": "merchant_location", "merchant_name": "merchant_name", "ocr_request_id": "ocr_request_id", "ocr_status": "ocr_status", "partner_metadata": { "key": "value" }, "sender": "hello@example.com", "source_of_data": "ocr", "total_amount": 1, "transaction_id": "transaction_id" } ``` **SDK Code** ```python import requests url = "https://api.sandbox.monite.com/v1/receipts/receipt_id/attach_file" files = { "file": "open('', 'rb')" } headers = { "x-monite-version": "2024-05-25", "x-monite-entity-id": "9d2b4c8f-2087-4738-ba91-7359683c49a4", "Authorization": "Bearer " } response = requests.post(url, files=files, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.sandbox.monite.com/v1/receipts/receipt_id/attach_file'; const form = new FormData(); form.append('file', ''); const options = { method: 'POST', headers: { 'x-monite-version': '2024-05-25', 'x-monite-entity-id': '9d2b4c8f-2087-4738-ba91-7359683c49a4', Authorization: 'Bearer ' } }; options.body = form; try { const response = await fetch(url, options); const data = await response.json(); console.log(data); } catch (error) { console.error(error); } ``` ```go package main import ( "fmt" "strings" "net/http" "io" ) func main() { url := "https://api.sandbox.monite.com/v1/receipts/receipt_id/attach_file" payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n") req, _ := http.NewRequest("POST", url, payload) req.Header.Add("x-monite-version", "2024-05-25") req.Header.Add("x-monite-entity-id", "9d2b4c8f-2087-4738-ba91-7359683c49a4") req.Header.Add("Authorization", "Bearer ") res, _ := http.DefaultClient.Do(req) defer res.Body.Close() body, _ := io.ReadAll(res.Body) fmt.Println(res) fmt.Println(string(body)) } ``` ```ruby require 'uri' require 'net/http' url = URI("https://api.sandbox.monite.com/v1/receipts/receipt_id/attach_file") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["x-monite-version"] = '2024-05-25' request["x-monite-entity-id"] = '9d2b4c8f-2087-4738-ba91-7359683c49a4' request["Authorization"] = 'Bearer ' request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n" response = http.request(request) puts response.read_body ``` ```java import com.mashape.unirest.http.HttpResponse; import com.mashape.unirest.http.Unirest; HttpResponse response = Unirest.post("https://api.sandbox.monite.com/v1/receipts/receipt_id/attach_file") .header("x-monite-version", "2024-05-25") .header("x-monite-entity-id", "9d2b4c8f-2087-4738-ba91-7359683c49a4") .header("Authorization", "Bearer ") .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n") .asString(); ``` ```php request('POST', 'https://api.sandbox.monite.com/v1/receipts/receipt_id/attach_file', [ 'multipart' => [ [ 'name' => 'file', 'filename' => '', 'contents' => null ] ] 'headers' => [ 'Authorization' => 'Bearer ', 'x-monite-entity-id' => '9d2b4c8f-2087-4738-ba91-7359683c49a4', 'x-monite-version' => '2024-05-25', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.sandbox.monite.com/v1/receipts/receipt_id/attach_file"); var request = new RestRequest(Method.POST); request.AddHeader("x-monite-version", "2024-05-25"); request.AddHeader("x-monite-entity-id", "9d2b4c8f-2087-4738-ba91-7359683c49a4"); request.AddHeader("Authorization", "Bearer "); request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody); IRestResponse response = client.Execute(request); ``` ```swift import Foundation let headers = [ "x-monite-version": "2024-05-25", "x-monite-entity-id": "9d2b4c8f-2087-4738-ba91-7359683c49a4", "Authorization": "Bearer " ] let parameters = [ [ "name": "file", "fileName": "" ] ] let boundary = "---011000010111000001101001" var body = "" var error: NSError? = nil for param in parameters { let paramName = param["name"]! body += "--\(boundary)\r\n" body += "Content-Disposition:form-data; name=\"\(paramName)\"" if let filename = param["fileName"] { let contentType = param["content-type"]! let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8) if (error != nil) { print(error as Any) } body += "; filename=\"\(filename)\"\r\n" body += "Content-Type: \(contentType)\r\n\r\n" body += fileContent } else if let paramValue = param["value"] { body += "\r\n\r\n\(paramValue)" } } let request = NSMutableURLRequest(url: NSURL(string: "https://api.sandbox.monite.com/v1/receipts/receipt_id/attach_file")! as URL, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) request.httpMethod = "POST" request.allHTTPHeaderFields = headers request.httpBody = postData as Data let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error as Any) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse) } }) dataTask.resume() ```