This POST API can be used to save (update) an existing Goods Receipt (GR) document in LEO by GEP. It is typically invoked from the UI on every save / auto-save action while the GR is in Draft. The endpoint accepts the full GR document (header + lines) as the payload and updates it in place.
URL Format: https://<Instance>/leo-gr-domaingateway-api/api/v1/SaveDocument
Notes / Behavior:
- documentId is REQUIRED in the payload. If missing or empty, the API performs no update and returns an empty GepReturn.
- The endpoint runs DAC (Data Access Control) validation. On failure the response contains an UnauthorizedAccessException ('Unauthorized').
- The current status / statusId / statusLocalizationKey of the GR header and each GR line are read from the database and OVERWRITTEN onto the payload before the update. Client-supplied status values are ignored - status can only be changed via dedicated transition endpoints (e.g., FinalizeDocument).
- The 'event' header value must be 'leo-gr-save'.
POST https://api-leogreenqc.gep.com/leo-gr-domaingateway-api/api/v1/SaveDocument
Sample Request Body (abbreviated):
{
"_id": "0495fd0b-cb33-4eed-a006-ca9c6a884a82",
"documentId": "0495fd0b-cb33-4eed-a006-ca9c6a884a82",
"grHeaderId": "0495fd0b-cb33-4eed-a006-ca9c6a884a82",
"rootId": "0495fd0b-cb33-4eed-a006-ca9c6a884a82",
"grNumber": "GR-2026.008835",
"documentName": "AutomReceipt202606202248iA0",
"documentNo": "",
"status": "Draft",
"statusId": 1,
"subTypeAppId": "39dd1c6a-2edc-40c7-b0d4-2e50755eb941",
"subType": 1,
"grType": 1,
"grTypeDetails": { "code": 1, "name": "Receipt" },
"orderNumber": "PO-2026-036249",
"orderRootId": "be32debe-c7bd-b2bf-31fd-960137a79b85",
"orderSubTypeAppId": "1e6cc0ad-5273-4e97-af3c-81f1eed2d112",
"orderType": "IndirectOrder",
"referenceDocumentNumber": "PO-2026-036249",
"source": "Order",
"purchaseType": "Standard",
"supplierCode": "PC-2024.004228",
"documentDate": "2026-06-20T22:48:19Z",
"postingDate": "2026-06-20T22:48:19Z",
"createdBy": "P2PAutomation Buyer",
"createdOn": "2026-06-20T22:48:19Z",
"updatedBy": "P2PAutomation Buyer",
"updatedOn": "2026-06-20T22:48:47Z",
"currency": { "isActive": true, "code": "USD", "name": "US Dollar" },
"dataSourceSystem": { "sourceSystemName": "Portal", "sourceSystemCode": 1 },
"supplier": { "...": "supplier object" },
"orderContact": { "...": "contact object" },
"orderAuthor": { "...": "contact object" },
"businessUnit": [ { "entityCode": "BU5", "entityName": "Business Unit 5" } ],
"shipToAddress": { "...": "address object" },
"orderDetails": [ { "orderNumber": "PO-2026-036249" } ],
"linkedDocuments": { "...": "linked PO references" },
"totalAcceptedQuantity": 80,
"totalOrderedQuantity": 80,
"totalReceivedQuantity": 80,
"totalReturnedQuantity": 0,
"auditFields": { "...": "audit fields" },
"grLine": [
{
"_id": "29a58111-a80e-4617-a48b-4eeb8933c9e6",
"grLineId": "29a58111-a80e-4617-a48b-4eeb8933c9e6",
"grLineNumber": "1",
"poNumber": "PO-2026-036249",
"poLineNumber": "1",
"orderedQuantity": 20,
"receivedQuantity": 20,
"deliveredQty": 20,
"lineType": "Material",
"category": "AIRFARE",
"customerItemDescription": "Laptop",
"itemName": "Laptop",
"itemUOM": "EA",
"unitPrice": 10,
"priceBasis": "Quantity Based",
"status": "Draft"
}
]
}
{
"isSuccess": true,
"errorMessage": null,
"errorCode": null,
"returnValue": null,
"hasData": false,
"hasException": false,
"exception": null
}
Success Scenario - Request
curl 'https://api-leogreenqc.gep.com/leo-gr-domaingateway-api/api/v1/SaveDocument' \
-H 'accept: application/json' \
-H 'content-type: application/json' \
-H 'authorization: Bearer <token>' \
-H 'ocp-apim-subscription-key: <subscription-key>' \
-H 'subtypeappid: 39dd1c6a-2edc-40c7-b0d4-2e50755eb941' \
-H 'event: leo-gr-save' \
-H 'x-gep-transaction-scope-id: 5bdd1aa0-2f0d-48de-8776-c5360ba77e64' \
--data-raw '<full GR document JSON>'
Success Scenario - Response
{
"isSuccess": true,
"errorMessage": null,
"errorCode": null,
"returnValue": null,
"hasData": false,
"hasException": false,
"exception": null
}
Failure Scenario - Response (DAC unauthorized)
{
"isSuccess": false,
"errorMessage": null,
"errorCode": null,
"returnValue": null,
"hasData": false,
"hasException": true,
"exception": {
"ClassName": "System.UnauthorizedAccessException",
"Message": "Unauthorized"
}
}
| Property | Required? | Data type | Description | Validations / Exceptions |
|---|---|---|---|---|
| Request Headers | ||||
| accept | Yes | String | Response media type. Use application/json. | |
| content-type | Yes | String | Payload media type. Use application/json. | |
| authorization | Yes | String | Bearer token used for authentication. | |
| ocp-apim-subscription-key | Yes | String | APIM subscription key issued to the consumer. | |
| subtypeappid | Yes | GUID (String) | Sub-type application identifier of the Goods Receipt module. | |
| event | Yes | String | Event name routing the request. Use leo-gr-save. | |
| x-gep-transaction-scope-id | Yes | GUID (String) | Unique transaction/correlation id sent by the source system. |
| Property | Required? | Data type | Description | Validations / Exceptions |
|---|---|---|---|---|
| SaveDocument Request Body (Header) | ||||
| documentId | Yes | String (GUID) | Document id of the GR being saved. Required - if missing the API performs no update. | Must be a valid existing GR documentId |
| _id | Yes | String (GUID) | Mongo internal id (root) of the GR document. | |
| grHeaderId | Yes | String (ObjectId) | Header object id of the GR. | |
| rootId | Yes | String (GUID) | Root document id (same as documentId for root GR). | |
| grNumber | Yes | String (100) | Goods Receipt number. | |
| documentName | String (200) | Display name of the GR document. | ||
| documentNo | String | Document number; may be blank prior to first finalize. | ||
| status | Yes | String | Current status. Server will OVERWRITE this from DB on save (client-supplied value is ignored). | Read-only on save - server overrides |
| statusId | Yes | Integer | Numeric status id. Also server-overwritten on save. | Read-only on save |
| subTypeAppId | Yes | GUID (String) | Sub-type application id of the GR module. | |
| subType | Yes | Integer | Numeric sub-type identifier. | |
| grType | Yes | Integer | Numeric GR type identifier. | |
| grTypeDetails | Object | GR type code + name pair (e.g., {code:1,name:'Receipt'}). | ||
| orderNumber | Yes | String | Purchase Order number against which the GR is being saved. | |
| orderRootId | Yes | String (GUID) | Root id of the referenced PO. | |
| orderSubTypeAppId | Yes | GUID (String) | Sub-type app id of the source order. | |
| orderType | Yes | String | Source order type (e.g., IndirectOrder). | |
| referenceDocumentNumber | String | Reference document number (typically PO number). | ||
| source | Yes | String | Document source (Order, ASN, etc.). | |
| purchaseType | String | Type of purchase: Standard / Direct / Indirect. | ||
| supplierCode | Yes | String | Client partner code of the supplier on this GR. | |
| documentDate | Yes | DateTime (ISO 8601) | Document date of the Goods Receipt. | Valid ISO datetime |
| postingDate | Yes | DateTime (ISO 8601) | Posting date of the GR in the ERP. | Valid ISO datetime |
| createdBy | String | Full name of the user who created the GR. | ||
| createdOn | DateTime (ISO 8601) | Timestamp when the GR was created. | ||
| updatedBy | String | Full name of the user who last updated the GR. | ||
| updatedOn | DateTime (ISO 8601) | Timestamp of last update. | ||
| currency | Currency object | Currency of the GR (code, name, symbol, isActive). | ||
| dataSourceSystem | Object | Source system metadata (sourceSystemName, sourceSystemCode). | ||
| supplier | Supplier object | Supplier details (clientPartnerCode, supplierName, supplierContact, locations). | ||
| orderContact | Contact object | Order contact details. | ||
| orderAuthor | Contact object | Order author details. | ||
| businessUnit | List of BusinessUnit object | Business unit(s) associated with the GR including parent org entities. | ||
| shipToAddress | Address object | Ship-to address of the GR. | ||
| orderDetails | List of OrderDetail object | Array of referenced PO details (orderNumber, orderRootId, orderDocumentId). | ||
| linkedDocuments | LinkedDocuments object | Linked PO/ASN document references. | ||
| totalAcceptedQuantity | Decimal | Sum of accepted quantities across all GR lines. | ||
| totalOrderedQuantity | Decimal | Sum of ordered quantities across all GR lines. | ||
| totalReceivedQuantity | Decimal | Sum of received quantities across all GR lines. | ||
| totalReturnedQuantity | Decimal | Sum of returned quantities across all GR lines. | ||
| auditFields | AuditFields object | Audit fields (createdBy, modifiedBy, transactionScopeId, ver). | ||
| customerInterface | Object | Customer interface sync state (isSync, inProcessing). | ||
| supplierSyncStatus | Object | Supplier sync metadata (syncDate, isSync, isProcessing). | ||
| notes | List of Notes object | Notes / attachments on the header. | ||
| attachmentLink | List of Attachment object | Header-level attachments. | ||
| version | String | Document version string (e.g., '0000'). | ||
| isModified | Boolean | Whether the GR has been modified after first finalize. | ||
| isDeleted | Boolean | Soft-delete flag. | ||
| isApprove | Boolean | Whether the GR is in approval flow. | ||
| isAutoReceipt | Boolean | Whether the GR was auto-created. | ||
| isErsEnabled | Boolean | Whether ERS is enabled for this supplier. | ||
| grLine | Yes | List of GRLine object | Array of GR line items. Check Data Type GRLine for details. | At least one line |
| Property | Required? | Data type | Description | Validations / Exceptions |
|---|---|---|---|---|
| GRLine | ||||
| _id | Yes | String (GUID) | Internal id of the GR line. | |
| grLineId | Yes | String (GUID) | GR line id (typically same as _id). | |
| grLineNumber | Yes | String | Line number on the Goods Receipt. | |
| grNumber | Yes | String | GR number this line belongs to. | |
| grHeaderId | Yes | String | Parent GR header id. | |
| documentId | Yes | String | Parent GR document id. | |
| rootId | Yes | String | Root id of the GR. | |
| rootLineId | Yes | String | Root line id. | |
| parent_id | String | Parent document id reference. | ||
| root_id | String | Root document id reference. | ||
| poNumber | Yes | String | PO number this line references. | |
| poLineNumber | Yes | String | Line number on the referenced PO. | |
| poIDClientCode | String (GUID) | Internal id of the referenced PO. | ||
| poLineIDClientCode | String (GUID) | Internal id of the referenced PO line. | ||
| poRootId | String (GUID) | Root id of the referenced PO. | ||
| poRootLineId | String (GUID) | Root line id of the referenced PO line. | ||
| orderedQuantity | Yes | Decimal | Ordered quantity on the PO line. | |
| orderedAmount | Decimal | Ordered amount on the PO line. | ||
| receivedQuantity | Yes | Decimal | Quantity received on this line. | Must be >= 0 |
| receivedQuantityRounded | Decimal | Received quantity rounded to UOM precision. | ||
| receivedAmount | Decimal | Received amount (amount-based lines). | ||
| deliveredQty | Yes | Decimal | Delivered quantity. | Must be >= 0 |
| deliveredQtyRounded | Decimal | Delivered quantity rounded. | ||
| deliveredAmount | Decimal | Delivered amount. | ||
| correctedQuantity | Decimal | Corrected quantity (post-receipt correction). | ||
| defectiveQuantity | Decimal | Defective quantity. | ||
| returnedQuantity | Decimal | Returned quantity. | ||
| previouslyAcceptedQuantity | Decimal | Previously accepted on the PO line. | ||
| previouslyReceivedQuantity | Decimal | Previously received on the PO line. | ||
| receivedDate | Yes | DateTime | Date the goods were received. | |
| acceptedDate | DateTime | Date the line was accepted. | ||
| needByDate | DateTime | Need-by date from the PO line. | ||
| lineType | Yes | String | Type of line (Material, Service, Tax). | |
| lineItemType | Object | Line item type {code, name}. | ||
| linePriceBasis | Object | Line price basis {code, name} (Quantity Based / Amount Based). | ||
| priceBasis | String | Price basis string. | ||
| category | String | Category of the line item. | ||
| itemName | String | Item name. | ||
| customerItemDescription | String | Customer item description. | ||
| itemUOM | String | Unit of measure code. | ||
| itemUOMDesc | String | Unit of measure description. | ||
| uomDecimalPrecision | Integer | Decimal precision allowed for UOM. | ||
| allowDecimalForUOM | Boolean | Whether decimal quantities are allowed. | ||
| unitPrice | Decimal | Unit price for the line. | ||
| currency | String | Currency display name. | ||
| currencyCode | String | Currency ISO code. | ||
| status | String | Line status. Server overrides on save. | Read-only on save | |
| statusId | Integer | Numeric line status id. Server overrides on save. | Read-only on save | |
| statusDetails | Object | Status code + default text pair. | ||
| shipToSite | String | Ship-to site of the line. | ||
| shipToSiteOrg | String | Ship-to site organisation/address. | ||
| source | String | Document source for the line. | ||
| orderName | String | Order name reference. | ||
| orderReferenceModelSubtype | String | Subtype of referenced order (e.g., IndirectOrder). | ||
| orderContact | Contact object | Order contact at the line level. | ||
| orderAuthor | Contact object | Order author at the line level. | ||
| requestor | Contact object | Requestor at the line level. | ||
| fulfilmentDocumentType | Object | Fulfilment doc type (code, name, description, clientCode). | ||
| grLot | List of GRLot object | Lot/batch breakdown for batch-controlled items. | ||
| isBatchControlled | Boolean | Whether the item is batch/lot controlled. | ||
| isDeleted | Boolean | Soft-delete flag for the line. | ||
| isModified | Boolean | Whether the line was modified. | ||
| isNotesAttach | Boolean | Whether notes/attachments exist on the line. | ||
| notes | List of Notes object | Notes / attachments on the line. | ||
| auditFields | AuditFields object | Audit fields for the line. | ||
| sourceAppId | String | Source application id. | ||
| sourceSystemGRNumber | String | Source system GR number on the line. |
| Property | Required? | Data type | Description | Validations / Exceptions |
|---|---|---|---|---|
| SaveDocument Response (GepReturn) | ||||
| isSuccess | Boolean | True if the save succeeded, false otherwise. | ||
| errorMessage | String | Error message text when isSuccess is false. | ||
| errorCode | JToken / String | Error code (or structured token) when applicable. | ||
| returnValue | Object | Typically null. May contain updated document depending on flow. | ||
| hasData | Boolean | Convenience flag: returnValue != null. | ||
| hasException | Boolean | Convenience flag: true if exception captured. | ||
| exception | Object | Exception details. UnauthorizedAccessException when DAC validation fails. |