Skip to main content

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

ParameterRequiredValue
Emailrequiredstring(50) The API user with specific permission to create documents and get information about your own documents into a company. Example: api@magnifinance.com
TokenrequiredThe token of the subscription in which the document will be generated.
note

*These parameters must be HTTP headers within the request.

Query

ParameterRequiredDescription
DocumentIdrequiredint 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

ParameterDescription
Typeint 0 = Success; 1 = Error; "Success" or "Error". Object will be returned on Success; ErrorValue, ErrorHumanReadable, ValidationErrors will be returned on Error. Example value: "0"
Objectnull
ErrorMessagestring Unprocessed error message.
ErrorValueMagniEnum
Valueint Identifies the error with a number. To identify the types of errors in more detail, click here. Example value: "14"
Namestring Identifies the error with a token. Example value: "SaveFailed"
ErrorHumanReadablestring Text that explains the error found. Example value: "ValidationError"
ValidationErrorsList of ValidationError
Typestring Identifies the error with a token. Example value: "DocumentIsADuplicate"
Fieldstring Name of the field in which validation failed. Example value: "DocumentDetailExternalId"
Valuestring Value which failed validation. Example value: "6"
ElementNumberint Identifies index of the field in which validation failed. Example value: "67204"
Detailstring Detailed error explanation. Example value: "Duplicate Document"
IsErrorboolean Whether the request failed or not. Example value: "false"
IsSuccessboolean 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")