This is Payabli documentation. For a complete page index, fetch https://docs.payabli.com/llms.txt — append .md to any page URL for lightweight markdown. For section-level indexes, query parameters, and other AI-optimized access methods, see https://docs.payabli.com/ai-agents.md

# 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.0
info:
  title: payabliApi
  version: 1.0.0
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:
            application/json:
              schema:
                description: Any type
        '401':
          description: Unauthorized request.
          content:
            application/json:
              schema:
                description: Any type
        '500':
          description: Internal API Error
          content:
            application/json:
              schema:
                description: Any type
        '503':
          description: Database connection error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/type_:PayabliApiResponse'
      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'
servers:
  - url: https://api-sandbox.payabli.com/api
  - url: https://api.payabli.com/api
components:
  schemas:
    type_ocr:typeResult:
      type: string
      description: >-
        The type of object to create in Payabli. Accepted values are `bill` and
        `invoice`.
      title: typeResult
    type_:FileContentFtype:
      type: string
      enum:
        - pdf
        - doc
        - docx
        - jpg
        - jpeg
        - png
        - gif
        - txt
      description: The MIME type of the file (if content is provided)
      title: FileContentFtype
    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
      title: FileContentImageOnly
    type_:IsSuccess:
      type: boolean
      description: >-
        Boolean indicating whether the operation was successful. A `true` value
        indicates success. A `false` value indicates failure.
      title: IsSuccess
    type_:ResponseText:
      type: string
      description: 'Response text for operation: ''Success'' or ''Declined''.'
      title: ResponseText
    type_:Responsecode:
      type: integer
      description: >-
        Code for the response. Learn more in [API Response
        Codes](/developers/api-reference/api-responses).
      title: Responsecode
    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
      title: OcrBillItem
    type_ocr:OcrBillItemAdditionalData:
      type: object
      properties:
        category:
          type: string
        currency_code:
          type: string
        type:
          type: string
        reference_number:
          type: string
      title: OcrBillItemAdditionalData
    type_:Email:
      type: string
      format: email
      description: Email address.
      title: Email
    type_:AdditionalDataString:
      type: string
      description: >-
        Custom dictionary of key:value pairs. You can use this field to store
        any data related to the object or for your system. Example usage: 


        ```json

        {
          "additionalData": {
            "key1": "value1",
            "key2": "value2",
            "key3": "value3"
          }
        }

        ```
      title: AdditionalDataString
    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'
      title: Contacts
    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
      title: OcrVendorBillingData
    type_ocr:OcrVendorAdditionalData:
      type: object
      properties:
        web:
          type: string
      title: OcrVendorAdditionalData
    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'
      title: OcrVendor
    type_ocr:OcrAttachment:
      type: object
      properties:
        ftype:
          type: string
        filename:
          type: string
        fileDescriptor:
          type: string
        furl:
          type: string
        fContent:
          type: string
      title: OcrAttachment
    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'
      title: OcrResultData
    type_ocr:OcrResponseData:
      type: object
      properties:
        resultData:
          $ref: '#/components/schemas/type_ocr:OcrResultData'
      title: OcrResponseData
    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
      title: PayabliApiResponseOCR
    type_:Responsedata:
      type: object
      additionalProperties:
        description: Any type
      description: The object containing the response data.
      title: Responsedata
    type_:PayabliApiResponse:
      type: object
      properties:
        isSuccess:
          $ref: '#/components/schemas/type_:IsSuccess'
        responseData:
          $ref: '#/components/schemas/type_:Responsedata'
        responseText:
          $ref: '#/components/schemas/type_:ResponseText'
      required:
        - responseText
      title: PayabliApiResponse
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: requestToken

```

## SDK Code Examples

```typescript
import { PayabliClient } from "@payabli/sdk-node";

async function main() {
    const client = new PayabliClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.ocr.ocrDocumentForm("typeResult", {});
}
main();

```

```python
from payabli import payabli

client = payabli(
    api_key="YOUR_API_KEY_HERE",
)

client.ocr.ocr_document_form(
    type_result="typeResult",
)

```

```csharp
using PayabliPayabliApi;
using System.Threading.Tasks;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new PayabliPayabliApiClient(
            apiKey: "YOUR_API_KEY_HERE"
        );

        await client.Ocr.OcrDocumentFormAsync(
            "typeResult",
            new FileContentImageOnly()
        );
    }

}

```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api-sandbox.payabli.com/api/Import/ocrDocumentForm/typeResult"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("requestToken", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	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.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"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api-sandbox.payabli.com/api/Import/ocrDocumentForm/typeResult")
  .header("requestToken", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api-sandbox.payabli.com/api/Import/ocrDocumentForm/typeResult', [
  'body' => '{}',
  'headers' => [
    'Content-Type' => 'application/json',
    'requestToken' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```swift
import Foundation

let headers = [
  "requestToken": "<apiKey>",
  "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()
```