(Deprecated) Ingest Documents via JSON

This API is deprecated and no more supported due to scaling issues.

Upload a sale or purchase document with JSON payload.

A maximum of 100 invoice line item objects can be ingested in one request.

Request Method

POST

Request URL

{{BASE_URL}}/integration/v2/ingest/json/{{templateType}}

Replace the {{BASE_URL}} with the one mentioned here based on whether you are using sandbox or production.

Request Headers

Parameter
Data Type
Field Validations
Description

x-cleartax-auth-token

String

Cannot be empty.

x-cleartax-gstin

String

Cannot be empty

Mandatory. GSTIN of the taxpayer registered on CFC.

Content-Type

String

application/json

Request Path Params

Parameter
Data Type
Field Validations
Description

templateType

String

Enum:

sales,

purchase

Type of document. sales - Sales document.

purchase- Purchase document.

Request Query Params

There are no query parameters for this API.

Request Body

Parameter
Data Type
Field Validation
Description

userInputArgs

Object

NA

jsonRecords

Array

MaxLength: 100

User Input Arguments Object

Parameter
Data Type
Field Validation
Description

templateId

String

NA

groupId

String

NA

Unique ID across the PAN to group a set of documents as a single record on the Clear Import History page.

Default: Autogenerated random ID.

settings

Object

NA

Settings Object

Parameter
Data Type
Field Validation
Description

ignoreHsnValidation

Boolean

NA

Optional. Indicates if HSN validation has to be ignored or not.

true - HSN validation error will be ignored.

false - HSN validation error will not be ignored. Default: false

Sample Request

Sales document

{
    "userInputArgs": {
        "templateId": "618a5623836651c01c1498ad", 
        "groupId": "TEST123",
        "settings": {
            "ignoreHsnValidation": true
        }
    }, 
    "jsonRecords": [
        {
            "documentType": "Invoice", 
            "documentDate": "2022-11-29", 
            "documentNumber": "Inv-123", 
            
            "erpSource": "Tally", 
            "voucherNumber": "Inv-123", 
            "voucherDate": "2022-11-29", 
            
            "isBillOfSupply": "N", 
            "isReverseCharge": "N", 
            "isDocumentCancelled": "N", 

            "supplierName": "Defmacro Software Private Limited", 
            "supplierGstin": "29AAFCD5862R1ZR", 

            "customerName": "Clearsharp Technology Private Limited", 
            "customerAddress": "Cust1 Mst Addr1, Cust1 Mst Addr2, Cust1 Mst Addr3", 
            "customerState": "Karnataka", 
            "customerGstin": "29AAECC3822D1ZY", 
            "placeOfSupply": "Karnataka", 

            "itemDescription": "Item1", 
            "itemCategory": "G", 
            "hsnSacCode": "48", 
            "itemQuantity": 500, 
            "itemUnitCode": "PCS", 
            "itemUnitPrice": 250, 
            "itemDiscount": 0, 
            "itemTaxableAmount": 125000, 
            "cgstRate": 9, 
            "cgstAmount": 11250, 
            "sgstRate": 9, 
            "sgstAmount": 11250, 
            "igstRate": 0, 
            "igstAmount": 0, 
            "cessRate": 0, 
            "cessAmount": 0, 

            "documentTotalAmount": 147500
        }
    ]
}

Purchase document

{
    "userInputArgs": {
        "templateId": "60e5613ff71f4a7aeca4336b", 
        "settings": {
            "ignoreHsnValidation": true
        }
    }, 
    "jsonRecords": [
        {
            "documentType": "Invoice", 
            "documentDate": "2022-11-29", 
            "documentNumber": "Inv-123", 
            
            "erpSource": "Tally", 
            "voucherNumber": "Inv-123", 
            "voucherDate": "2022-11-29", 
            
            "isBillOfSupply": "N", 
            "isReverseCharge": "N", 
            "isDocumentCancelled": "N", 

            "supplierGstin": "29AAECC3822D1ZY", 
            "supplierName": "Clearsharp Technology Private Limited", 
            "supplierAddress": "Cust1 Mst Addr1, Cust1 Mst Addr2, Cust1 Mst Addr3", 
            "supplierState": "Karnataka", 
            
            "customerGstin": "29AAFCD5862R1ZR", 

            "placeOfSupply": "Karnataka", 

            "itemDescription": "Item1", 
            "itemCategory": "G", 
            "hsnSacCode": "48", 
            "itemQuantity": 500, 
            "itemUnitCode": "PCS", 
            "itemUnitPrice": 250, 
            "itemDiscount": 0, 
            "itemTaxableAmount": 125000, 
            "cgstRate": 9, 
            "cgstAmount": 11250, 
            "sgstRate": 9, 
            "sgstAmount": 11250, 
            "igstRate": 0, 
            "igstAmount": 0, 
            "cessRate": 0, 
            "cessAmount": 0, 

            "documentTotalAmount": 147500
        }
    ]
}

Response Status Codes

HTTP Status Code
Description

200

For a successfully processed request (may be a success or validation error).

400

If the request schema is not valid.

401

If the user is not authenticated for the operation.

403

If the user is not authorized for the operation.

500

If there are any unhandled exceptions on Clear side.

Response Schema

Parameter
Data Type
Field Constraints
Description

gstinStats

Array

NA

jsonRecordErrors

Array

NA

errors

Array

NA

GSTIN Stats Object

Parameter
Data Type
Field Constraints
Description

gstin

String

NA

Seller GSTIN that these stats belong to.

totalDocumentCount

Number

NA

Total count of documents parsed successfully.

validRows

Number

NA

Total count of valid document line objects.

invalidRows

Number

NA

Total count of invalid document line objects.

JSON Record Error Details Object

Parameter
Data Type
Field Constraints
Description

recordIndex

Number

NA

Array index of the record in request jsonRecords. The index starts from 0.

recordErrors

Array

NA

externalId

String

NA

External ID that was sent in the request to identify the document, if any. In case an external ID was not sent, this field will not exist.

externalLineItemId

String

NA

External ID that was sent in the request to identify the document line item, if any. In case an external ID was not sent, this field will not exist.

Record Error Details Object

Parameter
Data Type
Field Constraints
Description

errorId

String

NA

Error ID

columnName

Array

NA

Array of strings representing field keys in the jsonRecords of the request that has an error.

errorMessage

String

NA

User friendly error message.

Non-Validation Error Details Object

Parameter
Data Type
Field Constraints
Description

errorCode

String

NA

Error code

errorMessage

String

NA

Error message.

errorField

NA

Error field.

errorValues

NA

Error values.

errorResolution

NA

Error resolution.

Sample Response

Success - HTTP Status Code - 200

{
  "gstinStats": [
    {
      "gstin": "29AAFCD5862R1ZR",
      "totalDocumentCount": 1,
      "validRows": 1,
      "invalidRows": 0
    }
  ],
  "jsonRecordErrors": [...],
  "errors": null
}

Validation Error - HTTP Status Code - 200

{
  "gstinStats": [
    {
      "gstin": "29AAFCD5862R1ZR",
      "totalDocumentCount": 0,
      "validRows": 0,
      "invalidRows": 1
    }
  ],
  "jsonRecordErrors": [
    {
      "recordIndex": 0,
      "externalId": "INVOICE_maxitc123_06ADECO9084R5Z4_29AAFCD5862R000_2022_0",
      "externalLineItemId": "INVOICE_maxitc123_06ADECO9084R5Z4_29AAFCD5862R000_2022_0",
      "recordErrors": [
        {
          "errorId": "HSN_OR_SAC_TYPE_ERROR",
          "columnName": ["hsnSacCode"],
          "errorMessage": "1234 is not a valid HSN "
        }
      ]
    }
  ],
  "errors": null
}

Non-Validation Error - HTTP Status Code - 401

{
  "gstinStats": [],
  "jsonRecordErrors": [],
  "errors": [
    {
      "errorCode": "AUTHORIZATION_FAILED",
      "errorMessage": "Invalid Auth Token",
      "errorField": null,
      "errorValues": null,
      "errorResolution": null
    }
  ]
}

Non-Validation Error - HTTP Status Code - 500

{
  "gstinStats": [],
  "jsonRecordErrors": [],
  "errors": [
    {
      "errorCode": "INTERNAL_ERROR",
      "errorMessage": "Internal Service Error",
      "errorField": null,
      "errorValues": null,
      "errorResolution": null
    }
  ]
}

API Validations

There are more than 200 field validations as well as business validations on the Clear API side. For data validation errors, the validation error message will be sent back in the `jsonRecordErrors` field in the response.

API Constraints

  1. This API needs to be authenticated with a valid user authentication token. If the auth token is not present or is invalid, the API will return HTTP Status Code 401.

  2. If the auth token is valid, but the user does not have the authorization, then the API will return HTTP Status Code 403. The user, whose auth token is used, should have permission to create a document.

Integrating for MaxITC?

If you are integrating with Max ITC, once the documents are uploaded, trigger the reconciliation using the Trigger MaxITC Workflow API.

Last updated