SaveDocument (POST)

Overview

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'.
 

Request
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"
        }
    ]
}
Response
{
    "isSuccess": true,
    "errorMessage": null,
    "errorCode": null,
    "returnValue": null,
    "hasData": false,
    "hasException": false,
    "exception": null
}
Examples
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"
    }
}
 
Data Elements

 

PropertyRequired?Data typeDescriptionValidations / Exceptions
Request Headers    
acceptYesStringResponse media type. Use application/json. 
content-typeYesStringPayload media type. Use application/json. 
authorizationYesStringBearer token used for authentication. 
ocp-apim-subscription-keyYesStringAPIM subscription key issued to the consumer. 
subtypeappidYesGUID (String)Sub-type application identifier of the Goods Receipt module. 
eventYesStringEvent name routing the request. Use leo-gr-save. 
x-gep-transaction-scope-idYesGUID (String)Unique transaction/correlation id sent by the source system. 

 

PropertyRequired?Data typeDescriptionValidations / Exceptions
SaveDocument Request Body (Header)    
documentIdYesString (GUID)Document id of the GR being saved. Required - if missing the API performs no update.Must be a valid existing GR documentId
_idYesString (GUID)Mongo internal id (root) of the GR document. 
grHeaderIdYesString (ObjectId)Header object id of the GR. 
rootIdYesString (GUID)Root document id (same as documentId for root GR). 
grNumberYesString (100)Goods Receipt number. 
documentName String (200)Display name of the GR document. 
documentNo StringDocument number; may be blank prior to first finalize. 
statusYesStringCurrent status. Server will OVERWRITE this from DB on save (client-supplied value is ignored).Read-only on save - server overrides
statusIdYesIntegerNumeric status id. Also server-overwritten on save.Read-only on save
subTypeAppIdYesGUID (String)Sub-type application id of the GR module. 
subTypeYesIntegerNumeric sub-type identifier. 
grTypeYesIntegerNumeric GR type identifier. 
grTypeDetails ObjectGR type code + name pair (e.g., {code:1,name:'Receipt'}). 
orderNumberYesStringPurchase Order number against which the GR is being saved. 
orderRootIdYesString (GUID)Root id of the referenced PO. 
orderSubTypeAppIdYesGUID (String)Sub-type app id of the source order. 
orderTypeYesStringSource order type (e.g., IndirectOrder). 
referenceDocumentNumber StringReference document number (typically PO number). 
sourceYesStringDocument source (Order, ASN, etc.). 
purchaseType StringType of purchase: Standard / Direct / Indirect. 
supplierCodeYesStringClient partner code of the supplier on this GR. 
documentDateYesDateTime (ISO 8601)Document date of the Goods Receipt.Valid ISO datetime
postingDateYesDateTime (ISO 8601)Posting date of the GR in the ERP.Valid ISO datetime
createdBy StringFull name of the user who created the GR. 
createdOn DateTime (ISO 8601)Timestamp when the GR was created. 
updatedBy StringFull name of the user who last updated the GR. 
updatedOn DateTime (ISO 8601)Timestamp of last update. 
currency Currency objectCurrency of the GR (code, name, symbol, isActive). 
dataSourceSystem ObjectSource system metadata (sourceSystemName, sourceSystemCode). 
supplier Supplier objectSupplier details (clientPartnerCode, supplierName, supplierContact, locations). 
orderContact Contact objectOrder contact details. 
orderAuthor Contact objectOrder author details. 
businessUnit List of BusinessUnit objectBusiness unit(s) associated with the GR including parent org entities. 
shipToAddress Address objectShip-to address of the GR. 
orderDetails List of OrderDetail objectArray of referenced PO details (orderNumber, orderRootId, orderDocumentId). 
linkedDocuments LinkedDocuments objectLinked PO/ASN document references. 
totalAcceptedQuantity DecimalSum of accepted quantities across all GR lines. 
totalOrderedQuantity DecimalSum of ordered quantities across all GR lines. 
totalReceivedQuantity DecimalSum of received quantities across all GR lines. 
totalReturnedQuantity DecimalSum of returned quantities across all GR lines. 
auditFields AuditFields objectAudit fields (createdBy, modifiedBy, transactionScopeId, ver). 
customerInterface ObjectCustomer interface sync state (isSync, inProcessing). 
supplierSyncStatus ObjectSupplier sync metadata (syncDate, isSync, isProcessing). 
notes List of Notes objectNotes / attachments on the header. 
attachmentLink List of Attachment objectHeader-level attachments. 
version StringDocument version string (e.g., '0000'). 
isModified BooleanWhether the GR has been modified after first finalize. 
isDeleted BooleanSoft-delete flag. 
isApprove BooleanWhether the GR is in approval flow. 
isAutoReceipt BooleanWhether the GR was auto-created. 
isErsEnabled BooleanWhether ERS is enabled for this supplier. 
grLineYesList of GRLine objectArray of GR line items. Check Data Type GRLine for details.At least one line

 

PropertyRequired?Data typeDescriptionValidations / Exceptions
GRLine    
_idYesString (GUID)Internal id of the GR line. 
grLineIdYesString (GUID)GR line id (typically same as _id). 
grLineNumberYesStringLine number on the Goods Receipt. 
grNumberYesStringGR number this line belongs to. 
grHeaderIdYesStringParent GR header id. 
documentIdYesStringParent GR document id. 
rootIdYesStringRoot id of the GR. 
rootLineIdYesStringRoot line id. 
parent_id StringParent document id reference. 
root_id StringRoot document id reference. 
poNumberYesStringPO number this line references. 
poLineNumberYesStringLine 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. 
orderedQuantityYesDecimalOrdered quantity on the PO line. 
orderedAmount DecimalOrdered amount on the PO line. 
receivedQuantityYesDecimalQuantity received on this line.Must be >= 0
receivedQuantityRounded DecimalReceived quantity rounded to UOM precision. 
receivedAmount DecimalReceived amount (amount-based lines). 
deliveredQtyYesDecimalDelivered quantity.Must be >= 0
deliveredQtyRounded DecimalDelivered quantity rounded. 
deliveredAmount DecimalDelivered amount. 
correctedQuantity DecimalCorrected quantity (post-receipt correction). 
defectiveQuantity DecimalDefective quantity. 
returnedQuantity DecimalReturned quantity. 
previouslyAcceptedQuantity DecimalPreviously accepted on the PO line. 
previouslyReceivedQuantity DecimalPreviously received on the PO line. 
receivedDateYesDateTimeDate the goods were received. 
acceptedDate DateTimeDate the line was accepted. 
needByDate DateTimeNeed-by date from the PO line. 
lineTypeYesStringType of line (Material, Service, Tax). 
lineItemType ObjectLine item type {code, name}. 
linePriceBasis ObjectLine price basis {code, name} (Quantity Based / Amount Based). 
priceBasis StringPrice basis string. 
category StringCategory of the line item. 
itemName StringItem name. 
customerItemDescription StringCustomer item description. 
itemUOM StringUnit of measure code. 
itemUOMDesc StringUnit of measure description. 
uomDecimalPrecision IntegerDecimal precision allowed for UOM. 
allowDecimalForUOM BooleanWhether decimal quantities are allowed. 
unitPrice DecimalUnit price for the line. 
currency StringCurrency display name. 
currencyCode StringCurrency ISO code. 
status StringLine status. Server overrides on save.Read-only on save
statusId IntegerNumeric line status id. Server overrides on save.Read-only on save
statusDetails ObjectStatus code + default text pair. 
shipToSite StringShip-to site of the line. 
shipToSiteOrg StringShip-to site organisation/address. 
source StringDocument source for the line. 
orderName StringOrder name reference. 
orderReferenceModelSubtype StringSubtype of referenced order (e.g., IndirectOrder). 
orderContact Contact objectOrder contact at the line level. 
orderAuthor Contact objectOrder author at the line level. 
requestor Contact objectRequestor at the line level. 
fulfilmentDocumentType ObjectFulfilment doc type (code, name, description, clientCode). 
grLot List of GRLot objectLot/batch breakdown for batch-controlled items. 
isBatchControlled BooleanWhether the item is batch/lot controlled. 
isDeleted BooleanSoft-delete flag for the line. 
isModified BooleanWhether the line was modified. 
isNotesAttach BooleanWhether notes/attachments exist on the line. 
notes List of Notes objectNotes / attachments on the line. 
auditFields AuditFields objectAudit fields for the line. 
sourceAppId StringSource application id. 
sourceSystemGRNumber StringSource system GR number on the line. 

 

PropertyRequired?Data typeDescriptionValidations / Exceptions
SaveDocument Response (GepReturn)    
isSuccess BooleanTrue if the save succeeded, false otherwise. 
errorMessage StringError message text when isSuccess is false. 
errorCode JToken / StringError code (or structured token) when applicable. 
returnValue ObjectTypically null. May contain updated document depending on flow. 
hasData BooleanConvenience flag: returnValue != null. 
hasException BooleanConvenience flag: true if exception captured. 
exception ObjectException details. UnauthorizedAccessException when DAC validation fails.