Cancel a Document
Changes the document state to canceled and updates the PDF.
Endpoint
PATCH https://bo.magnifinance.com/api/v1.1/document?documentId={DocumentId}
Request
Header
| Parameter | Required | Value |
|---|---|---|
| required | string(50) The API user with specific permission to create documents and get information about your own documents into a company. Example: api@magnifinance.com | |
| Token | required | The token of the subscription in which the document will be generated. |
note
*These parameters must be HTTP headers within the request.
Query
| Parameter | Required | Description |
|---|---|---|
| DocumentId | required | int Id of the document that you want to delete. Example value: "67053". In the REST API you should request as a query string parameter in the URL. Example: ?documentId=67053 |
Response
| Parameter | Description |
|---|---|
| Type | int 0 = Success; 1 = Error; "Success" or "Error". Object will be returned on Success; ErrorValue, ErrorHumanReadable, ValidationErrors will be returned on Error. Example value: "0" |
| Object | null |
| ErrorMessage | string Unprocessed error message. |
| ErrorValue | MagniEnum |
| Value | int Identifies the error with a number. To identify the types of errors in more detail, click here. Example value: "14" |
| Name | string Identifies the error with a token. Example value: "SaveFailed" |
| ErrorHumanReadable | string Text that explains the error found. Example value: "ValidationError" |
| ValidationErrors | List of ValidationError |
| Type | string Identifies the error with a token. Example value: "DocumentIsADuplicate" |
| Field | string Name of the field in which validation failed. Example value: "DocumentDetailExternalId" |
| Value | string Value which failed validation. Example value: "6" |
| ElementNumber | int Identifies index of the field in which validation failed. Example value: "67204" |
| Detail | string Detailed error explanation. Example value: "Duplicate Document" |
| IsError | boolean Whether the request failed or not. Example value: "false" |
| IsSuccess | boolean Whether the request succeeded or not. Example value: "true" |
Request Samples
Below you can check some examples of the REST request in some technologies.
cURL
curl --location --request PATCH 'https://bo.magnifinance.com/api/v1.1/document?documentId={DOCUMENTID}' \
--header 'email: XXX@example.com' \
--header 'token: XXX'
JavaScript (fetch)
var myHeaders = new Headers();
myHeaders.append("email", "XXX@example.com");
myHeaders.append("token", "XXX");
var requestOptions = {
method: 'PATCH',
headers: myHeaders,
redirect: 'follow'
};
fetch("https://bo.magnifinance.com/api/v1.1/document?documentId={DOCUMENTID}", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Node.js (axios)
var axios = require('axios');
var config = {
method: 'patch',
url: 'https://bo.magnifinance.com/api/v1.1/document?documentId={DOCUMENTID}',
headers: {
'email': 'XXX@example.com',
'token': 'XXX'
}
};
axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});
Python (requests)
import requests
url = "https://bo.magnifinance.com/api/v1.1/document"
headers = {
"email": "XXX@example.com",
"token": "XXX"
}
params = {
"documentId": "{DOCUMENTID}"
}
response = requests.patch(url, headers=headers, params=params)
print(response.json())
PHP (cURL)
<?php
$documentId = "{DOCUMENTID}";
$url = "https://bo.magnifinance.com/api/v1.1/document?documentId=" . $documentId;
$headers = [
"email: XXX@example.com",
"token: XXX"
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>
C# (HttpClient)
using System.Net.Http;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("email", "XXX@example.com");
client.DefaultRequestHeaders.Add("token", "XXX");
var documentId = "{DOCUMENTID}";
var request = new HttpRequestMessage(
HttpMethod.Patch,
$"https://bo.magnifinance.com/api/v1.1/document?documentId={documentId}"
);
var response = await client.SendAsync(request);
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
Java (HttpClient)
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
HttpClient client = HttpClient.newHttpClient();
String documentId = "{DOCUMENTID}";
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://bo.magnifinance.com/api/v1.1/document?documentId=" + documentId))
.header("email", "XXX@example.com")
.header("token", "XXX")
.method("PATCH", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = client.send(request,
HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
Example Response
Success
{
"RequestId": "88202672-2e68-4f90-8055-e6e2120f401f",
"Object": null,
"Type": 0,
"ErrorValue": null,
"ErrorHumanReadable": null,
"ValidationErrors": null,
"IsSuccess": true,
"IsError": false
}
Error
{
"RequestId": "bd3f677a-f7c5-4c30-9c01-6aefaab2b7be",
"Object": null,
"Type": 1,
"ErrorValue": {
"Value": 6,
"Name": "ElementDoesNotExist"
},
"ErrorHumanReadable": null,
"ValidationErrors": null,
"IsSuccess": false,
"IsError": true
}
Important
- Only documents that are in "Closed" state can be cancelled
- Cancelling a document is irreversible
- The document's PDF will be updated to reflect the cancelled status
- A cancelled document remains in the system with status "Cancelled" (status code "A")