# Delete a contract file Building with an AI agent? Start at https://docs.payme.io/agents.md - Sandbox: `DELETE https://sandbox.payme.io/api/payment-contracts/{payment_contract_guid}/invoices/{invoice_guid}` - Production: `DELETE https://live.payme.io/api/payment-contracts/{payment_contract_guid}/invoices/{invoice_guid}` ## Credentials - Header `PayMe-Merchant-Key` (required): Your `seller_payme_id` (MPL). You must be the seller that uploaded the file. Deletes a file you uploaded to a contract. Only the seller who uploaded the file can delete it (error `385`). Send `Content-Type: application/json` and a JSON body that isn't empty, for example `{"confirm": true}`. A DELETE without a JSON body fails with error `900` or `901`. If the contract has no file with this `invoice_guid`, the call returns success (`status_code` `0`) and deletes nothing. ### Errors HTTP status | Error code | Message | When ---|---|---|--- `400` | `251` | Seller was not found | The `PayMe-Merchant-Key` header is missing. `status_additional_info` is the header name. `400` | `385` | Action not allowed - please contact Customer Support | This seller is neither side of the contract. `status_additional_info` is the seller key. `400` | `385` | Action not allowed - please contact Customer Support | This seller may not delete this file. `500` | `251` | Seller was not found | The seller key is unknown. `500` | `163` | Account settings problem - please contact Customer Support | The seller is not active. `500` | `380` | Payment contract not found | No contract has this GUID. `status_additional_info` is the GUID. `500` | `900` | Please provide all required information in JSON format. Make sure to include 'Content-Type: application/json' header | The request is not JSON. `500` | `901` | Please verify that the JSON provided is valid | The JSON body is empty or invalid. ## Parameters | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `PayMe-Merchant-Key` | header | string | yes | Your `seller_payme_id` (MPL). You must be the seller that uploaded the file. | | `payment_contract_guid` | path | string | yes | The contract's `guid`, as returned when the contract was created, e.g. `CONT1700-000000AA-EXAMPLE1-CONT0001`. It already starts with `CONT`; don't add another prefix. | | `invoice_guid` | path | string | yes | The file's `id` (`INV…`), as returned by [Upload contract files](/b2b-payments/contracts/post-contracts-files) or [List contract files](/b2b-payments/contracts/get-contracts-files). | ## Request body Content type: `application/json` Required: any JSON object that isn't empty, e.g. `{"confirm": true}`. PayMe doesn't read its content. ### Request example ```json { "confirm": true } ``` ## Code samples ### curl ```bash curl -X DELETE 'https://sandbox.payme.io/api/payment-contracts//invoices/' \ -H 'Content-Type: application/json' \ -H 'PayMe-Merchant-Key: ' \ --data-raw '{ "confirm": true }' ``` ### Node.js ```javascript const response = await fetch("https://sandbox.payme.io/api/payment-contracts//invoices/", { method: "DELETE", headers: { "Content-Type": "application/json", "PayMe-Merchant-Key": "", }, body: JSON.stringify({ "confirm": true }), }); console.log(await response.text()); ``` ### Python ```python import requests response = requests.delete( "https://sandbox.payme.io/api/payment-contracts//invoices/", headers={ "PayMe-Merchant-Key": "", }, json={ "confirm": True, }, ) print(response.text) ``` ### PHP ```php /invoices/'); curl_setopt_array($ch, [ CURLOPT_CUSTOMREQUEST => 'DELETE', CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ 'Content-Type: application/json', 'PayMe-Merchant-Key: ', ], CURLOPT_POSTFIELDS => $body, ]); $response = curl_exec($ch); curl_close($ch); echo $response; ``` ## Responses ### 200 — The file was deleted, or the contract has no file with this `invoice_guid`. (success) | Field | Type | Description | | --- | --- | --- | | `status_code` | integer | `0` on success. | | `session` | string | PayMe session ID. Quote it when you contact PayMe support. | ```json { "status_code": 0, "session": "FhT3aXe7" } ``` ### 400 — Bad Request (error) | Field | Type | Description | | --- | --- | --- | | `status_code` | number | Status code 1 (for failure) | | `status_error_details` | string | What caused the error | | `status_additional_info` | string | The parameters related to the error | | `status_error_code` | number | Status error code | | `session` | string | PayMe session ID. | ```json { "status_code": 1, "status_error_details": "Seller was not found", "status_additional_info": "PayMe-Merchant-Key", "status_error_code": 251, "session": "FhT3aXe7" } ``` ### 500 — Internal Server Error (error) | Field | Type | Description | | --- | --- | --- | | `status_code` | number | Status code 1 (for failure) | | `status_error_details` | string | What caused the error | | `status_additional_info` | string | The parameters related to the error | | `status_error_code` | number | Status error code | | `session` | string | PayMe session ID. | ```json { "status_code": 1, "status_error_details": "Seller was not found", "status_additional_info": "seller_payme_id", "status_error_code": 251, "session": "FhT3aXe7" } ```