> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.monite.com/v2023-09-01/api/ocr/post-ocr-tasks-upload-from-file/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.monite.com/_mcp/server. # Upload a file for OCR POST https://api.sandbox.monite.com/v1/ocr_tasks/upload_from_file Content-Type: multipart/form-data Reference: https://docs.monite.com/api/ocr/post-ocr-tasks-upload-from-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 ### Query parameters - `document_type` (enum, optional) - Allowed values: `invoice`, `credit_note`, `receipt` ### Headers - `x-monite-version` (string, required) - `x-monite-entity-id` (string, optional) — 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 ### 202 OCR task has been accepted for execution. - `id` (string, required) - `created_at` (datetime, required) - `updated_at` (datetime, required) - `status` (enum, required) - Allowed values: `processing`, `success`, `error` - `document_type` (enum, optional) - Allowed values: `invoice`, `credit_note`, `receipt` - `recognized_data` (OcrTaskResponseSchemaRecognizedData, optional) ## Errors ### 400 Post OCR Tasks Upload from File Request Bad Request Error OCR failed to process the specified file. - `any` ### 413 Post OCR Tasks Upload from File Request Content Too Large Error File size exceeds the limit for OCR processing. - `any` ### 415 Post OCR Tasks Upload from File Request Unsupported Media Type Error Unsupported file format. OCR supports only PNG, JPG, and PDF. - `any` ### 422 Post OCR Tasks Upload from File Request Unprocessable Entity Error File name is too long. - `any` ### 500 Post OCR Tasks Upload from File Request Internal Server Error Internal Server Error - `error` (ErrorSchema, required) ## Types ### OcrTaskResponseSchemaRecognizedData - `type`: `invoice` - `recipient` (OcrCounterpartDetails, required) - `sender` (OcrCounterpartDetails, required) - `amount_paid` (double, optional) - `currency` (enum, optional) - 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` - `document_number` (string, optional) - `due_date` (string, optional) - `issue_date` (string, optional) - `line_items` (list of OcrLineItem, optional) - `payment_terms` (string, optional) - `subtotal` (double, optional) - `tax_amount` (double, optional) - `tax_rate` (double, optional) - `total_amount` (double, optional) - `type`: `credit_note` - `line_items` (list of OcrLineItem, required) - `recipient` (OcrCounterpartDetails, required) - `sender` (OcrCounterpartDetails, required) - `currency` (enum, optional) - 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` - `document_number` (string, optional) - `issue_date` (string, optional) - `original_invoice_number` (string, optional) - `subtotal` (double, optional) - `tax_amount` (double, optional) - `tax_rate` (double, optional) - `total_amount` (double, optional) - `type`: `receipt` - `line_items` (list of OcrReceiptLineItem, required) - `sender` (OcrCounterpartDetails, required) - `currency` (enum, optional) - 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` - `discount` (double, optional) - `document_number` (string, optional) - `issued_at` (datetime, optional) - `subtotal` (double, optional) - `tax_amount` (double, optional) - `tax_rate` (double, optional) - `tax_type` (string, optional) - `total_amount` (double, optional) ### ErrorSchema - `message` (string, required) ### OcrCounterpartDetails - `address` (OcrAddressDetails, required) - `bank_account` (OcrBankDetails, required) - `email` (string, optional) - `name` (string, optional) - `tax_number` (string, optional) - `vat_number` (string, optional) ### OcrLineItem - `description` (string, optional) - `line_reference` (string, optional) - `name` (string, optional) - `quantity` (double, optional) - `subtotal` (double, optional) - `tax_amount` (double, optional) - `tax_rate` (double, optional) - `total_amount` (double, optional) - `unit` (string, optional) - `unit_price` (double, optional) ### OcrReceiptLineItem - `description` (string, optional) - `discount_amount` (double, optional) - `line_reference` (string, optional) - `name` (string, optional) - `quantity` (double, optional) - `subtotal` (double, optional) - `tax_amount` (double, optional) - `tax_rate` (double, optional) - `total_amount` (double, optional) - `unit` (string, optional) - `unit_price` (double, optional) ### OcrAddressDetails - `city` (string, optional) - `country` (enum, optional) - Allowed values: `AF`, `AX`, `AL`, `DZ`, `AS`, `AD`, `AO`, `AI`, `AQ`, `AG`, `AR`, `AM`, `AW`, `AU`, `AT`, `AZ`, `BS`, `BH`, `BD`, `BB`, `BY`, `BE`, `BZ`, `BJ`, `BM`, `BT`, `BO`, `BA`, `BW`, `BV`, `BR`, `IO`, `BN`, `BG`, `BF`, `BI`, `KH`, `CM`, `CA`, `IC`, `CV`, `KY`, `CF`, `EA`, `TD`, `CL`, `CN`, `CX`, `CC`, `CO`, `KM`, `CG`, `CD`, `CK`, `CR`, `CI`, `HR`, `CU`, `CY`, `CZ`, `DK`, `DJ`, `DM`, `DO`, `EC`, `EG`, `SV`, `GQ`, `ER`, `EE`, `SZ`, `ET`, `FK`, `FO`, `FJ`, `FI`, `FR`, `GF`, `PF`, `TF`, `GA`, `GM`, `GE`, `DE`, `GH`, `GI`, `GR`, `GL`, `GD`, `GP`, `GU`, `GT`, `GG`, `GN`, `GW`, `GY`, `HT`, `HM`, `VA`, `HN`, `HK`, `HU`, `IS`, `IN`, `ID`, `IR`, `IQ`, `IE`, `IM`, `IL`, `IT`, `JM`, `JP`, `JE`, `JO`, `KZ`, `KE`, `KI`, `KP`, `KR`, `KW`, `KG`, `LA`, `LV`, `LB`, `LS`, `LR`, `LY`, `LI`, `LT`, `LU`, `MO`, `MG`, `MW`, `MY`, `MV`, `ML`, `MT`, `MH`, `MQ`, `MR`, `MU`, `YT`, `MX`, `FM`, `MD`, `MC`, `MN`, `ME`, `MS`, `MA`, `MZ`, `MM`, `NA`, `NR`, `NP`, `NL`, `AN`, `NC`, `NZ`, `NI`, `NE`, `NG`, `NU`, `NF`, `MP`, `MK`, `NO`, `OM`, `PK`, `PW`, `PS`, `PA`, `PG`, `PY`, `PE`, `PH`, `PN`, `PL`, `PT`, `PR`, `QA`, `RE`, `RO`, `RU`, `RW`, `SH`, `KN`, `LC`, `PM`, `VC`, `WS`, `SM`, `ST`, `SA`, `SN`, `RS`, `SC`, `SL`, `SG`, `SK`, `SI`, `SB`, `SO`, `ZA`, `SS`, `GS`, `ES`, `LK`, `SD`, `SR`, `SJ`, `SE`, `CH`, `SY`, `TW`, `TJ`, `TZ`, `TH`, `TL`, `TG`, `TK`, `TO`, `TT`, `TN`, `TR`, `TM`, `TC`, `TV`, `UG`, `UA`, `AE`, `GB`, `US`, `UM`, `UY`, `UZ`, `VU`, `VE`, `VN`, `VG`, `VI`, `WF`, `EH`, `YE`, `ZM`, `ZW`, `BL`, `BQ`, `CW`, `MF`, `SX` - `postal_code` (string, optional) - `state` (string, optional) - `street_and_number` (string, optional) ### OcrBankDetails - `bank_account_number` (string, optional) - `iban` (string, optional) - `swift_bic` (string, optional) ## Examples **Request** ```json { "file": ">" } ``` **Response** ```json { "id": "id", "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z", "status": "processing", "document_type": "invoice", "recognized_data": { "type": "invoice", "recipient": { "address": { "city": "city", "country": "AF", "postal_code": "postal_code", "state": "state", "street_and_number": "street_and_number" }, "bank_account": { "bank_account_number": "bank_account_number", "iban": "iban", "swift_bic": "swift_bic" }, "email": "email", "name": "name", "tax_number": "tax_number", "vat_number": "vat_number" }, "sender": { "address": { "city": "city", "country": "AF", "postal_code": "postal_code", "state": "state", "street_and_number": "street_and_number" }, "bank_account": { "bank_account_number": "bank_account_number", "iban": "iban", "swift_bic": "swift_bic" }, "email": "email", "name": "name", "tax_number": "tax_number", "vat_number": "vat_number" }, "amount_paid": 1.1, "currency": "AED", "document_number": "document_number", "due_date": "due_date", "issue_date": "issue_date", "line_items": [ { "description": "description", "line_reference": "line_reference", "name": "name", "quantity": 1.1, "subtotal": 1.1, "tax_amount": 1.1, "tax_rate": 1.1, "total_amount": 1.1, "unit": "unit", "unit_price": 1.1 } ], "payment_terms": "payment_terms", "subtotal": 1.1, "tax_amount": 1.1, "tax_rate": 1.1, "total_amount": 1.1 } } ``` **SDK Code** ```python import requests url = "https://api.sandbox.monite.com/v1/ocr_tasks/upload_from_file" files = { "file": "open('', 'rb')" } headers = { "x-monite-version": "2023-09-01", "Authorization": "Bearer " } response = requests.post(url, files=files, headers=headers) print(response.json()) ``` ```javascript const url = 'https://api.sandbox.monite.com/v1/ocr_tasks/upload_from_file'; const form = new FormData(); form.append('file', ''); const options = { method: 'POST', headers: {'x-monite-version': '2023-09-01', 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/ocr_tasks/upload_from_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", "2023-09-01") 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/ocr_tasks/upload_from_file") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["x-monite-version"] = '2023-09-01' 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/ocr_tasks/upload_from_file") .header("x-monite-version", "2023-09-01") .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/ocr_tasks/upload_from_file', [ 'multipart' => [ [ 'name' => 'file', 'filename' => '', 'contents' => null ] ] 'headers' => [ 'Authorization' => 'Bearer ', 'x-monite-version' => '2023-09-01', ], ]); echo $response->getBody(); ``` ```csharp using RestSharp; var client = new RestClient("https://api.sandbox.monite.com/v1/ocr_tasks/upload_from_file"); var request = new RestRequest(Method.POST); request.AddHeader("x-monite-version", "2023-09-01"); 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": "2023-09-01", "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/ocr_tasks/upload_from_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() ```