# OCR PDF or image POST https://api-sandbox.payabli.com/api/Import/ocrDocumentForm/{typeResult} Content-Type: application/json Use this endpoint to upload an image file for OCR processing. The accepted file formats include PDF, JPG, JPEG, PNG, and GIF. Specify the desired type of result (either 'bill' or 'invoice') in the path parameter `typeResult`. The response will contain the OCR processing results, including extracted data such as bill number, vendor information, bill items, and more. Reference: https://docs.payabli.com/developers/api-reference/import/ocr-a-file ## OpenAPI Specification ```yaml openapi: 3.1.1 info: title: Ocr Document Form version: endpoint_ocr.OcrDocumentForm paths: /Import/ocrDocumentForm/{typeResult}: post: operationId: ocr-document-form summary: Ocr Document Form description: >- Use this endpoint to upload an image file for OCR processing. The accepted file formats include PDF, JPG, JPEG, PNG, and GIF. Specify the desired type of result (either 'bill' or 'invoice') in the path parameter `typeResult`. The response will contain the OCR processing results, including extracted data such as bill number, vendor information, bill items, and more. tags: - - subpackage_ocr parameters: - name: typeResult in: path required: true schema: $ref: '#/components/schemas/type_ocr:typeResult' - name: requestToken in: header required: true schema: type: string responses: '200': description: OCR document processing result content: application/json: schema: $ref: '#/components/schemas/type_ocr:PayabliApiResponseOCR' '400': description: Bad request/ invalid data content: {} '401': description: Unauthorized request. content: {} '500': description: Internal API Error content: {} '503': description: Database connection error content: {} requestBody: description: >- The image file to OCR. Accepted formats include PDF, JPG, JPEG, PNG, GIF. content: application/json: schema: $ref: '#/components/schemas/type_ocr:FileContentImageOnly' components: schemas: type_ocr:typeResult: type: string type_:FileContentFtype: type: string enum: - value: pdf - value: doc - value: docx - value: jpg - value: jpeg - value: png - value: gif - value: txt type_ocr:FileContentImageOnly: type: object properties: ftype: $ref: '#/components/schemas/type_:FileContentFtype' filename: type: string description: The name of the file to be uploaded furl: type: string description: Optional URL link to the file fContent: type: string description: Base64-encoded file content type_:IsSuccess: type: boolean type_:ResponseText: type: string type_:Responsecode: type: integer type_ocr:OcrBillItem: type: object properties: itemTotalAmount: type: number format: double itemTaxAmount: type: number format: double itemTaxRate: type: number format: double itemProductCode: type: string itemProductName: type: string itemDescription: type: string itemCommodityCode: type: string itemUnitOfMeasure: type: string itemCost: type: number format: double itemQty: type: integer itemMode: type: integer itemCategories: type: array items: type: string type_ocr:OcrBillItemAdditionalData: type: object properties: category: type: string currency_code: type: string type: type: string reference_number: type: string type_:Email: type: string format: email type_:AdditionalDataString: type: string type_:Contacts: type: object properties: contactEmail: $ref: '#/components/schemas/type_:Email' description: Contact email address. contactName: type: string description: Contact name. contactPhone: type: string description: Contact phone number. contactTitle: type: string description: Contact title. additionalData: $ref: '#/components/schemas/type_:AdditionalDataString' type_ocr:OcrVendorBillingData: type: object properties: id: type: integer bankName: type: string routingAccount: type: string accountNumber: type: string typeAccount: type: string bankAccountHolderName: type: string bankAccountHolderType: type: string bankAccountFunction: type: integer type_ocr:OcrVendorAdditionalData: type: object properties: web: type: string type_ocr:OcrVendor: type: object properties: vendorNumber: type: string name1: type: string name2: type: string ein: type: string phone: type: string email: type: string address1: type: string address2: type: string city: type: string state: type: string zip: type: string country: type: string mcc: type: string locationCode: type: string contacts: type: array items: $ref: '#/components/schemas/type_:Contacts' billingData: $ref: '#/components/schemas/type_ocr:OcrVendorBillingData' paymentMethod: type: string vendorStatus: type: integer remitAddress1: type: string remitAddress2: type: string remitCity: type: string remitState: type: string remitZip: type: string remitCountry: type: string payeeName1: type: string payeeName2: type: string customerVendorAccount: type: string internalReferenceId: type: integer format: int64 customField1: type: string customField2: type: string additionalData: $ref: '#/components/schemas/type_ocr:OcrVendorAdditionalData' type_ocr:OcrAttachment: type: object properties: ftype: type: string filename: type: string fileDescriptor: type: string furl: type: string fContent: type: string type_ocr:OcrResultData: type: object properties: billNumber: type: string netAmount: type: number format: double billDate: type: string format: date-time dueDate: type: string format: date-time comments: type: string billItems: type: array items: $ref: '#/components/schemas/type_ocr:OcrBillItem' mode: type: integer accountingField1: type: string accountingField2: type: string additionalData: $ref: '#/components/schemas/type_ocr:OcrBillItemAdditionalData' vendor: $ref: '#/components/schemas/type_ocr:OcrVendor' endDate: type: string format: date-time frequency: type: string terms: type: string status: type: integer lotNumber: type: string attachments: type: array items: $ref: '#/components/schemas/type_ocr:OcrAttachment' type_ocr:OcrResponseData: type: object properties: resultData: $ref: '#/components/schemas/type_ocr:OcrResultData' type_ocr:PayabliApiResponseOCR: type: object properties: isSuccess: $ref: '#/components/schemas/type_:IsSuccess' responseText: $ref: '#/components/schemas/type_:ResponseText' responseCode: $ref: '#/components/schemas/type_:Responsecode' responseData: $ref: '#/components/schemas/type_ocr:OcrResponseData' description: Details of the OCR processing result required: - isSuccess - responseText - responseCode ``` ## SDK Code Examples ```python from payabli import payabli client = payabli( api_key="YOUR_API_KEY", ) client.ocr.ocr_document_form( type_result="typeResult", ) ``` ```typescript import { Payabli, PayabliClient } from "@payabli/sdk-node"; const client = new PayabliClient({ apiKey: "YOUR_API_KEY" }); await client.ocr.ocrDocumentForm("typeResult", {}); ``` ```go import ( context "context" option "github.com/payabli/sdk-go/option" sdkgo "github.com/payabli/sdk-go" sdkgoclient "github.com/payabli/sdk-go/client" ) client := sdkgoclient.NewClient( option.WithApiKey( "", ), ) response, err := client.Ocr.OcrDocumentForm( context.TODO(), "typeResult", &sdkgo.FileContentImageOnly{}, ) ``` ```csharp using PayabliApi; var client = new PayabliApiClient("API_KEY"); await client.Ocr.OcrDocumentFormAsync( "typeResult", new FileContentImageOnly { Ftype = null, Filename = null, Furl = null, FContent = null, } ); ``` ```ruby require 'uri' require 'net/http' url = URI("https://api-sandbox.payabli.com/api/Import/ocrDocumentForm/typeResult") http = Net::HTTP.new(url.host, url.port) http.use_ssl = true request = Net::HTTP::Post.new(url) request["requestToken"] = '' request["Content-Type"] = 'application/json' request.body = "{}" response = http.request(request) puts response.read_body ``` ```java HttpResponse response = Unirest.post("https://api-sandbox.payabli.com/api/Import/ocrDocumentForm/typeResult") .header("requestToken", "") .header("Content-Type", "application/json") .body("{}") .asString(); ``` ```php request('POST', 'https://api-sandbox.payabli.com/api/Import/ocrDocumentForm/typeResult', [ 'body' => '{}', 'headers' => [ 'Content-Type' => 'application/json', 'requestToken' => '', ], ]); echo $response->getBody(); ``` ```swift import Foundation let headers = [ "requestToken": "", "Content-Type": "application/json" ] let parameters = [] as [String : Any] let postData = JSONSerialization.data(withJSONObject: parameters, options: []) let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Import/ocrDocumentForm/typeResult")! 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() ```