> For the complete documentation index, see [llms.txt](https://developers.docstudio.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.docstudio.com/guides/envelope-callbacks.md). Agents can also search and read this documentation through its [MCP server](https://developers.docstudio.com/~gitbook/mcp).

# Envelope callbacks

This document explains how to configure callbacks for envelope updates, verify callback filters, test delivery, and process callback payloads in a receiving system.

Envelope callbacks allow DocStudio to notify a receiving endpoint when an envelope matches a configured filter. DocStudio sends the envelope data as JSON in an HTTP `POST` request, allowing a CRM, ERP, or another system to react to envelope changes without repeatedly requesting their status.

<figure><img src="https://2619072834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcOltVL8GwCu4tL8RwTDW%2Fuploads%2FcpYSqj0VscA0e5QQi7Lu%2FChatGPT%20Image%2014%20%D1%81%D0%B5%D0%BD%D1%82.%202026%20%D0%B3.%2C%2008_40_43.png?alt=media&amp;token=b00f96a3-6cea-4208-9978-d4eeebebf0ef" alt=""><figcaption></figcaption></figure>

For example, a CRM can receive a callback when a contract envelope reaches `COMPLETED`. The CRM can then find the corresponding contract by the saved envelope UUID and update its status automatically.

### Available operations

<table><thead><tr><th width="187.5555419921875">Operation</th><th width="431.0001220703125">Method and endpoint</th><th>Required identifiers</th></tr></thead><tbody><tr><td>Inspect the callback payload</td><td><code>GET /api/v1/envelope/callback/callbackRequestPayload</code></td><td>None</td></tr><tr><td>Create a callback</td><td><code>POST /api/v1/envelope/callback/add</code></td><td><code>Mailbox</code></td></tr><tr><td>Check an envelope against the filter</td><td><code>GET /api/v1/envelope/callback/{callbackUuid}/check</code></td><td><code>callbackUuid</code>, <code>envelopeUuid</code>, <code>mailboxUuid</code></td></tr><tr><td>Test callback delivery</td><td><code>GET /api/v1/envelope/callback/{callbackUuid}/send</code></td><td><code>callbackUuid</code>, <code>envelopeUuid</code>, <code>mailboxUuid</code></td></tr><tr><td>List callbacks</td><td><code>GET /api/v1/envelope/callback/list</code></td><td><code>Mailbox</code></td></tr><tr><td>Remove a callback</td><td><code>DELETE /api/v1/envelope/callback/{callbackUuid}/remove</code></td><td><code>callbackUuid</code>, <code>Mailbox</code></td></tr></tbody></table>

The main configuration workflow consists of inspecting the payload, creating the callback, checking its filter, and testing delivery. Listing and removing callbacks are separate management operations described in [Manage callbacks](#manage-callbacks).

### Callback settings

The create request defines where the callback is delivered, which envelopes match it, and how DocStudio handles delivery. The following properties control this behavior:

<table><thead><tr><th width="124">Property</th><th>Purpose</th></tr></thead><tbody><tr><td><code>url</code></td><td>URL of the receiving endpoint to which DocStudio sends callback requests</td></tr><tr><td><code>filter</code></td><td>Criteria that determine which envelopes trigger the callback</td></tr><tr><td><code>retries</code></td><td>Number of retry attempts after an unsuccessful delivery</td></tr><tr><td><code>timeout</code></td><td>Time in milliseconds that DocStudio waits for the receiving endpoint to respond</td></tr><tr><td><code>successCode</code></td><td>HTTP status code that confirms successful delivery</td></tr><tr><td><code>login</code></td><td>Optional username for Basic authentication</td></tr><tr><td><code>password</code></td><td>Optional password for Basic authentication</td></tr></tbody></table>

DocStudio waits for the configured `timeout` during each delivery attempt. It retries when the request times out or the endpoint returns an HTTP `5xx` response. The `retries` value sets the number of retries, for example, `retries: 3` means one initial attempt up to three retries.

A delivery succeeds when the endpoint returns the configured `successCode`. Any other non-`5xx` response does not confirm success. DocStudio only retries after a timeout or an HTTP `5xx` response.

DocStudio returns `authType` after creating the callback. It is `NONE` without authentication. It is `BASIC` when you provide `login` and `password`.

### Step 1 — Inspect the callback payload

Before implementing the receiving endpoint, retrieve the current callback payload structure.

DocStudio returns an example of the envelope data sent to the receiving endpoint:

{% tabs %}
{% tab title="Node.js" %}

```javascript
const response = await fetch(
  "https://api.docstudio.com/api/v1/envelope/callback/callbackRequestPayload",
  {
    headers: {
      Authorization: "Bearer {token}"
    }
  }
);

if (!response.ok) {
  throw new Error(`Request failed: ${response.status}`);
}

const payload = await response.json();
console.log(payload);
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init(
    "https://api.docstudio.com/api/v1/envelope/callback/callbackRequestPayload"
);

curl_setopt_array($curl, [
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer {token}"
    ],
    CURLOPT_RETURNTRANSFER => true
]);

$body = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
curl_close($curl);

if ($status !== 200) {
    throw new RuntimeException("Request failed: {$status}");
}

echo $body;
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

response = requests.get(
    "https://api.docstudio.com/api/v1/envelope/callback/callbackRequestPayload",
    headers={"Authorization": "Bearer {token}"},
    timeout=30,
)
response.raise_for_status()

payload = response.json()
print(payload)
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "net/http"
require "json"

uri = URI(
  "https://api.docstudio.com/api/v1/envelope/callback/callbackRequestPayload"
)
request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer {token}"

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

raise "Request failed: #{response.code}" unless response.is_a?(Net::HTTPSuccess)

payload = JSON.parse(response.body)
puts payload
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	request, err := http.NewRequest(
		http.MethodGet,
		"https://api.docstudio.com/api/v1/envelope/callback/callbackRequestPayload",
		nil,
	)
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer {token}")

	response, err := http.DefaultClient.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	if response.StatusCode != http.StatusOK {
		panic(fmt.Sprintf("Request failed: %s", response.Status))
	}

	body, err := io.ReadAll(response.Body)
	if err != nil {
		panic(err)
	}

	fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="Rust" %}

```bash
curl --request GET \
  --url 'https://api.docstudio.com/api/v1/envelope/callback/callbackRequestPayload' \
  --header 'Authorization: Bearer {token}'
```

{% endtab %}

{% tab title="Java" %}

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
  public static void main(String[] args) throws Exception {
    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create(
            "https://api.docstudio.com/api/v1/envelope/callback/callbackRequestPayload"
        ))
        .header("Authorization", "Bearer {token}")
        .GET()
        .build();

    HttpResponse<String> response = HttpClient.newHttpClient().send(
        request,
        HttpResponse.BodyHandlers.ofString()
    );

    if (response.statusCode() != 200) {
      throw new RuntimeException("Request failed: " + response.statusCode());
    }

    System.out.println(response.body());
  }
}
```

{% endtab %}

{% tab title=".NET" %}

```csharp
using System.Net.Http.Headers;

using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", "{token}");

using var response = await client.GetAsync(
    "https://api.docstudio.com/api/v1/envelope/callback/callbackRequestPayload"
);
response.EnsureSuccessStatusCode();

var payload = await response.Content.ReadAsStringAsync();
Console.WriteLine(payload);
```

{% endtab %}
{% endtabs %}

The `uuid` property identifies the envelope that triggered the callback. Save this UUID in the receiving system when the envelope is created or sent, and use it to associate subsequent callback requests with the correct business record.

DocStudio delivers this payload to the configured URL using an HTTP `POST` request:

```http
POST {receiverUrl}
Content-Type: application/json

{
  "uuid": "{envelopeUuid}",
  "status": "COMPLETED",
  "subject": "Service agreement",
  "label": [
    "contract"
  ],
  "receiveDate": "2026-09-01T11:12:58.635Z",
  "expireDate": "2026-09-30T23:59:59.000Z",
  "template": "{templateUuid}",
  "sender": "{senderMailboxUuid}",
  "mailbox": "{mailboxUuid}"
}
```

The receiving endpoint must process the JSON body and return the callback’s configured `successCode`. For a callback configured with `successCode: 200`, the expected response is:

```http
HTTP/1.1 200 OK
```

Return the success code after accepting the callback. Move long-running processing to a background job.

### Step 2 — Create the callback

Create a callback in the mailbox from which DocStudio should monitor envelopes:

{% tabs %}
{% tab title="Node.js" %}

```javascript
const payload = {
  url: "{receiverUrl}",
  retries: 3,
  timeout: 5000,
  successCode: 200,
  filter: {
    status: ["COMPLETED"],
    template: ["{templateUuid}"]
  }
};

const response = await fetch(
  "https://api.docstudio.com/api/v1/envelope/callback/add",
  {
    method: "POST",
    headers: {
      Authorization: "Bearer {token}",
      Mailbox: "{mailboxUuid}",
      "Content-Type": "application/json"
    },
    body: JSON.stringify(payload)
  }
);

const body = await response.text();

if (!response.ok) {
  throw new Error(
    `Request failed: ${response.status}\n${body}`
  );
}

console.log(body);
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

payload = {
    "url": "{receiverUrl}",
    "retries": 3,
    "timeout": 5000,
    "successCode": 200,
    "filter": {
        "status": ["COMPLETED"],
        "template": ["{templateUuid}"],
    },
}

response = requests.post(
    "https://api.docstudio.com/api/v1/envelope/callback/add",
    headers={
        "Authorization": "Bearer {token}",
        "Mailbox": "{mailboxUuid}",
    },
    json=payload,
    timeout=30,
)

response.raise_for_status()
print(response.text)
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --request POST \
  --url 'https://api.docstudio.com/api/v1/envelope/callback/add' \
  --header 'Authorization: Bearer {token}' \
  --header 'Mailbox: {mailboxUuid}' \
  --header 'Content-Type: application/json' \
  --data '{
    "url": "{receiverUrl}",
    "retries": 3,
    "timeout": 5000,
    "successCode": 200,
    "filter": {
      "status": [
        "COMPLETED"
      ],
      "template": [
        "{templateUuid}"
      ]
    }
  }'
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$payload = [
    "url" => "{receiverUrl}",
    "retries" => 3,
    "timeout" => 5000,
    "successCode" => 200,
    "filter" => [
        "status" => ["COMPLETED"],
        "template" => ["{templateUuid}"]
    ]
];

$curl = curl_init(
    "https://api.docstudio.com/api/v1/envelope/callback/add"
);

curl_setopt_array($curl, [
    CURLOPT_POST => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer {token}",
        "Mailbox: {mailboxUuid}",
        "Content-Type: application/json"
    ],
    CURLOPT_POSTFIELDS => json_encode(
        $payload,
        JSON_THROW_ON_ERROR
    ),
    CURLOPT_RETURNTRANSFER => true
]);

$response = curl_exec($curl);

if ($response === false) {
    $error = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException($error);
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("Request failed: {$status}");
}

echo $response;
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "net/http"
require "uri"
require "json"

uri = URI(
  "https://api.docstudio.com/api/v1/envelope/callback/add"
)

payload = {
  url: "{receiverUrl}",
  retries: 3,
  timeout: 5000,
  successCode: 200,
  filter: {
    status: ["COMPLETED"],
    template: ["{templateUuid}"]
  }
}

request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer {token}"
request["Mailbox"] = "{mailboxUuid}"
request["Content-Type"] = "application/json"
request.body = JSON.generate(payload)

response = Net::HTTP.start(
  uri.hostname,
  uri.port,
  use_ssl: uri.scheme == "https"
) do |http|
  http.request(request)
end

unless response.is_a?(Net::HTTPSuccess)
  raise "Request failed: #{response.code}"
end

puts response.body
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
)

func main() {
	payload := []byte(`{
	  "url": "{receiverUrl}",
	  "retries": 3,
	  "timeout": 5000,
	  "successCode": 200,
	  "filter": {
	    "status": ["COMPLETED"],
	    "template": ["{templateUuid}"]
	  }
	}`)

	request, err := http.NewRequest(
		http.MethodPost,
		"https://api.docstudio.com/api/v1/envelope/callback/add",
		bytes.NewReader(payload),
	)
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer {token}")
	request.Header.Set("Mailbox", "{mailboxUuid}")
	request.Header.Set("Content-Type", "application/json")

	response, err := http.DefaultClient.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	body, err := io.ReadAll(response.Body)
	if err != nil {
		panic(err)
	}

	if response.StatusCode < 200 || response.StatusCode >= 300 {
		panic(fmt.Sprintf(
			"Request failed: %s\n%s",
			response.Status,
			body,
		))
	}

	fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="Java" %}

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
  public static void main(String[] args) throws Exception {
    String payload = """
        {
          "url": "{receiverUrl}",
          "retries": 3,
          "timeout": 5000,
          "successCode": 200,
          "filter": {
            "status": ["COMPLETED"],
            "template": ["{templateUuid}"]
          }
        }
        """;

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create(
            "https://api.docstudio.com/api/v1/envelope/callback/add"
        ))
        .header("Authorization", "Bearer {token}")
        .header("Mailbox", "{mailboxUuid}")
        .header("Content-Type", "application/json")
        .POST(HttpRequest.BodyPublishers.ofString(payload))
        .build();

    HttpResponse<String> response =
        HttpClient.newHttpClient().send(
            request,
            HttpResponse.BodyHandlers.ofString()
        );

    if (response.statusCode() < 200 ||
        response.statusCode() >= 300) {
      throw new RuntimeException(
          "Request failed: " + response.statusCode()
          + "\n" + response.body()
      );
    }

    System.out.println(response.body());
  }
}
```

{% endtab %}

{% tab title=".NET" %}

```csharp
using System.Net.Http.Headers;
using System.Net.Http.Json;

using var client = new HttpClient();

var payload = new
{
    url = "{receiverUrl}",
    retries = 3,
    timeout = 5000,
    successCode = 200,
    filter = new
    {
        status = new[] { "COMPLETED" },
        template = new[] { "{templateUuid}" }
    }
};

using var request = new HttpRequestMessage(
    HttpMethod.Post,
    "https://api.docstudio.com/api/v1/envelope/callback/add"
)
{
    Content = JsonContent.Create(payload)
};

request.Headers.Authorization =
    new AuthenticationHeaderValue("Bearer", "{token}");
request.Headers.Add("Mailbox", "{mailboxUuid}");

using var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();

if (!response.IsSuccessStatusCode)
{
    throw new HttpRequestException(
        $"Request failed: {(int)response.StatusCode}\n{body}"
    );
}

Console.WriteLine(body);
```

{% endtab %}
{% endtabs %}

This example creates a callback for envelopes created from the specified template that have reached `COMPLETED`. The values `3`, `5000`, and `200` are example configuration values for `retries`, `timeout`, and `successCode`, respectively.

#### Callback filters

The `filter` object defines which envelopes can trigger the callback. DocStudio evaluates the configured criteria when an envelope changes and sends a callback only when the envelope matches the filter.

<table><thead><tr><th width="391">Filter category</th><th>Available properties</th></tr></thead><tbody><tr><td>Status and classification</td><td><code>status</code>, <code>label</code>, <code>subject</code></td></tr><tr><td>Template and sender</td><td><code>template</code>, <code>templateVersion</code>, <code>sender</code>, <code>form</code></td></tr><tr><td>Creation date</td><td><code>createDateFrom</code>, <code>createDateTo</code></td></tr><tr><td>Receiving date</td><td><code>receiveDateFrom</code>, <code>receiveDateTo</code></td></tr><tr><td>Expiration date</td><td><code>expireDateFrom</code>, <code>expireDateTo</code></td></tr><tr><td>Sending date</td><td><code>sendDateFrom</code>, <code>sendDateTo</code></td></tr><tr><td>Custom envelope data</td><td><code>metadata</code></td></tr></tbody></table>

Use stable shared criteria such as the template, status, sender, form, or label for production callbacks. For example, filtering by a specific `metadata.contractId` creates a callback for only one contract, while filtering by a template and status allows one callback to process all relevant contracts.

A successful create request returns `201 Created`. The response contains the saved configuration and the callback `id`:

```json
{
  "url": "{receiverUrl}",
  "retries": 3,
  "timeout": 5000,
  "successCode": 200,
  "id": "{callbackUuid}",
  "authType": "NONE",
  "filter": {
    "status": [
      "COMPLETED"
    ],
    "template": [
      "{templateUuid}"
    ]
  }
}
```

Save the returned `id` as the callback ID. This value is used as `{callbackUuid}` in endpoint paths.

#### Basic authentication

If the receiving endpoint requires Basic authentication, add `login` and `password` to the create request. DocStudio uses these credentials when it sends an HTTP `POST` request to the receiving endpoint.

```json
{
  "url": "{receiverUrl}",
  "retries": 3,
  "timeout": 5000,
  "successCode": 200,
  "login": "{receiverLogin}",
  "password": "{receiverPassword}",
  "filter": {
    "status": [
      "COMPLETED"
    ]
  }
}
```

The response for this configuration contains `authType: "BASIC"`. The `authType` property is generated by DocStudio and should not be added to the create request.

### Step 3 — Check the callback filter

Before testing delivery, check whether a specific envelope matches the callback filter:

{% tabs %}
{% tab title="Node.js" %}

```javascript
const url = new URL(
  "https://api.docstudio.com/api/v1/envelope/" +
  "callback/{callbackUuid}/check"
);

url.searchParams.set(
  "envelopeUuid",
  "{envelopeUuid}"
);
url.searchParams.set(
  "mailboxUuid",
  "{mailboxUuid}"
);

const response = await fetch(url, {
  method: "GET",
  headers: {
    Authorization: "Bearer {token}"
  }
});

const body = await response.text();

if (!response.ok) {
  throw new Error(
    `Request failed: ${response.status}\n${body}`
  );
}

console.log(body);
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$query = http_build_query([
    "envelopeUuid" => "{envelopeUuid}",
    "mailboxUuid" => "{mailboxUuid}"
]);

$url =
    "https://api.docstudio.com/api/v1/envelope/" .
    "callback/{callbackUuid}/check?" .
    $query;

$curl = curl_init($url);

curl_setopt_array($curl, [
    CURLOPT_HTTPGET => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer {token}"
    ],
    CURLOPT_RETURNTRANSFER => true
]);

$response = curl_exec($curl);

if ($response === false) {
    $error = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException($error);
}

$status = curl_getinfo(
    $curl,
    CURLINFO_RESPONSE_CODE
);
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException(
        "Request failed: {$status}\n{$response}"
    );
}

echo $response;
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

response = requests.get(
    "https://api.docstudio.com/api/v1/envelope/"
    "callback/{callbackUuid}/check",
    headers={
        "Authorization": "Bearer {token}",
    },
    params={
        "envelopeUuid": "{envelopeUuid}",
        "mailboxUuid": "{mailboxUuid}",
    },
    timeout=30,
)

response.raise_for_status()
print(response.text)
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "net/http"
require "uri"

uri = URI(
  "https://api.docstudio.com/api/v1/envelope/" \
  "callback/{callbackUuid}/check"
)

uri.query = URI.encode_www_form(
  envelopeUuid: "{envelopeUuid}",
  mailboxUuid: "{mailboxUuid}"
)

request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer {token}"

response = Net::HTTP.start(
  uri.hostname,
  uri.port,
  use_ssl: uri.scheme == "https"
) do |http|
  http.request(request)
end

unless response.is_a?(Net::HTTPSuccess)
  raise(
    "Request failed: #{response.code}\n" \
    "#{response.body}"
  )
end

puts response.body
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://api.docstudio.com/api/v1/envelope/" +
		"callback/{callbackUuid}/check" +
		"?envelopeUuid={envelopeUuid}" +
		"&mailboxUuid={mailboxUuid}"

	request, err := http.NewRequest(
		http.MethodGet,
		url,
		nil,
	)
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer {token}")

	response, err := http.DefaultClient.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	body, err := io.ReadAll(response.Body)
	if err != nil {
		panic(err)
	}

	if response.StatusCode < 200 || response.StatusCode >= 300 {
		panic(fmt.Sprintf(
			"Request failed: %s\n%s",
			response.Status,
			body,
		))
	}

	fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="Java" %}

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
  public static void main(String[] args) throws Exception {
    String url =
        "https://api.docstudio.com/api/v1/envelope/"
        + "callback/{callbackUuid}/check"
        + "?envelopeUuid={envelopeUuid}"
        + "&mailboxUuid={mailboxUuid}";

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create(url))
        .header("Authorization", "Bearer {token}")
        .GET()
        .build();

    HttpResponse<String> response =
        HttpClient.newHttpClient().send(
            request,
            HttpResponse.BodyHandlers.ofString()
        );

    if (response.statusCode() < 200 ||
        response.statusCode() >= 300) {
      throw new RuntimeException(
          "Request failed: " + response.statusCode()
          + "\n" + response.body()
      );
    }

    System.out.println(response.body());
  }
}
```

{% endtab %}

{% tab title=".NET" %}

```csharp
using System.Net.Http.Headers;

using var client = new HttpClient();

var url =
    "https://api.docstudio.com/api/v1/envelope/" +
    "callback/{callbackUuid}/check" +
    "?envelopeUuid={envelopeUuid}" +
    "&mailboxUuid={mailboxUuid}";

using var request = new HttpRequestMessage(
    HttpMethod.Get,
    url
);

request.Headers.Authorization =
    new AuthenticationHeaderValue(
        "Bearer",
        "{token}"
    );

using var response = await client.SendAsync(
    request
);

var body = await response.Content.ReadAsStringAsync();

if (!response.IsSuccessStatusCode)
{
    throw new HttpRequestException(
        $"Request failed: " +
        $"{(int)response.StatusCode}\n{body}"
    );
}

Console.WriteLine(body);
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --request GET \
  --url 'https://api.docstudio.com/api/v1/envelope/callback/{callbackUuid}/check?envelopeUuid={envelopeUuid}&mailboxUuid={mailboxUuid}' \
  --header 'Authorization: Bearer {token}'
```

{% endtab %}
{% endtabs %}

If the envelope satisfies every configured filter criterion, the response contains `passed: true`:

```json
{
  "passed": true,
  "failed": {}
}
```

If the envelope does not match the filter, `passed` is `false`. Inspect the returned `failed` object to identify which configured criteria were not satisfied. Each property shows the expected filter value that the envelope did not match.

```json
{
  "passed": false,
  "failed": {
    "status": [
      "COMPLETED"
    ]
  }
}
```

A failed check does not indicate a callback delivery error because no callback request has been sent yet. Verify the envelope’s current status, template, sender, dates, labels, form, or metadata against the callback filter.

### Step 4 — Test callback delivery

After confirming that the envelope matches the filter, send a test callback to the configured receiving endpoint:

{% tabs %}
{% tab title="Node.js" %}

```javascript
const url = new URL(
  "https://api.docstudio.com/api/v1/envelope/" +
  "callback/{callbackUuid}/send"
);

url.searchParams.set(
  "envelopeUuid",
  "{envelopeUuid}"
);
url.searchParams.set(
  "mailboxUuid",
  "{mailboxUuid}"
);

const response = await fetch(url, {
  method: "GET",
  headers: {
    Authorization: "Bearer {token}"
  }
});

const body = await response.text();

if (!response.ok) {
  throw new Error(
    `Request failed: ${response.status}\n${body}`
  );
}

console.log(body);
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$query = http_build_query([
    "envelopeUuid" => "{envelopeUuid}",
    "mailboxUuid" => "{mailboxUuid}"
]);

$url =
    "https://api.docstudio.com/api/v1/envelope/" .
    "callback/{callbackUuid}/send?" .
    $query;

$curl = curl_init($url);

curl_setopt_array($curl, [
    CURLOPT_HTTPGET => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer {token}"
    ],
    CURLOPT_RETURNTRANSFER => true
]);

$response = curl_exec($curl);

if ($response === false) {
    $error = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException($error);
}

$status = curl_getinfo(
    $curl,
    CURLINFO_RESPONSE_CODE
);
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException(
        "Request failed: {$status}\n{$response}"
    );
}

echo $response;
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

response = requests.get(
    "https://api.docstudio.com/api/v1/envelope/"
    "callback/{callbackUuid}/send",
    headers={
        "Authorization": "Bearer {token}",
    },
    params={
        "envelopeUuid": "{envelopeUuid}",
        "mailboxUuid": "{mailboxUuid}",
    },
    timeout=30,
)

response.raise_for_status()
print(response.text)
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "net/http"
require "uri"

uri = URI(
  "https://api.docstudio.com/api/v1/envelope/" \
  "callback/{callbackUuid}/send"
)

uri.query = URI.encode_www_form(
  envelopeUuid: "{envelopeUuid}",
  mailboxUuid: "{mailboxUuid}"
)

request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer {token}"

response = Net::HTTP.start(
  uri.hostname,
  uri.port,
  use_ssl: uri.scheme == "https"
) do |http|
  http.request(request)
end

unless response.is_a?(Net::HTTPSuccess)
  raise(
    "Request failed: #{response.code}\n" \
    "#{response.body}"
  )
end

puts response.body
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://api.docstudio.com/api/v1/envelope/" +
		"callback/{callbackUuid}/send" +
		"?envelopeUuid={envelopeUuid}" +
		"&mailboxUuid={mailboxUuid}"

	request, err := http.NewRequest(
		http.MethodGet,
		url,
		nil,
	)
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer {token}")

	response, err := http.DefaultClient.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	body, err := io.ReadAll(response.Body)
	if err != nil {
		panic(err)
	}

	if response.StatusCode < 200 || response.StatusCode >= 300 {
		panic(fmt.Sprintf(
			"Request failed: %s\n%s",
			response.Status,
			body,
		))
	}

	fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="Java" %}

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
  public static void main(String[] args) throws Exception {
    String url =
        "https://api.docstudio.com/api/v1/envelope/"
        + "callback/{callbackUuid}/send"
        + "?envelopeUuid={envelopeUuid}"
        + "&mailboxUuid={mailboxUuid}";

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create(url))
        .header("Authorization", "Bearer {token}")
        .GET()
        .build();

    HttpResponse<String> response =
        HttpClient.newHttpClient().send(
            request,
            HttpResponse.BodyHandlers.ofString()
        );

    if (response.statusCode() < 200 ||
        response.statusCode() >= 300) {
      throw new RuntimeException(
          "Request failed: " + response.statusCode()
          + "\n" + response.body()
      );
    }

    System.out.println(response.body());
  }
}
```

{% endtab %}

{% tab title=".NET" %}

```csharp
using System.Net.Http.Headers;

using var client = new HttpClient();

var url =
    "https://api.docstudio.com/api/v1/envelope/" +
    "callback/{callbackUuid}/send" +
    "?envelopeUuid={envelopeUuid}" +
    "&mailboxUuid={mailboxUuid}";

using var request = new HttpRequestMessage(
    HttpMethod.Get,
    url
);

request.Headers.Authorization =
    new AuthenticationHeaderValue(
        "Bearer",
        "{token}"
    );

using var response = await client.SendAsync(
    request
);

var body = await response.Content.ReadAsStringAsync();

if (!response.IsSuccessStatusCode)
{
    throw new HttpRequestException(
        $"Request failed: " +
        $"{(int)response.StatusCode}\n{body}"
    );
}

Console.WriteLine(body);
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --request GET \
  --url 'https://api.docstudio.com/api/v1/envelope/callback/{callbackUuid}/send?envelopeUuid={envelopeUuid}&mailboxUuid={mailboxUuid}' \
  --header 'Authorization: Bearer {token}'
```

{% endtab %}
{% endtabs %}

DocStudio sends an actual HTTP `POST` request with the callback payload to the configured receiving endpoint. The API response contains the HTTP status code and response body returned by that endpoint:

```json
{
  "code": 200,
  "body": "OK"
}
```

The returned `code` should match the callback’s configured `successCode`. If the receiving endpoint returns an HTTP `5xx` response or does not respond within the configured `timeout`, DocStudio retries the delivery according to `retries`.

### Production example — Update a CRM when a contract is completed

Suppose a CRM creates contract envelopes from the same DocStudio template. The CRM must update each contract record when its envelope reaches `COMPLETED`.

1. When the CRM creates or sends an envelope, save the returned envelope UUID in the corresponding contract record.
2. Create one callback filtered by the contract template UUID and the `COMPLETED` status.
3. When DocStudio sends a callback, read `uuid` and `status` from the payload.
4. Find the CRM contract whose saved envelope UUID matches the callback `uuid`.
5. If the contract has not already been updated, save the new envelope status.
6. Return the callback’s configured `successCode`.

<figure><img src="https://2619072834-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcOltVL8GwCu4tL8RwTDW%2Fuploads%2FT0QeWZLR8zbwCT2liL50%2F%D0%9E%D0%B1%D0%BD%D0%BE%D0%B2%D0%BB%D0%B5%D0%BD%D0%B8%D0%B5%20CRM%20%D0%BF%D0%BE%D1%81%D0%BB%D0%B5%20%D0%B7%D0%B0%D0%B2%D0%B5%D1%80%D1%88%D0%B5%D0%BD%D0%B8%D1%8F%20%D0%BA%D0%BE%D0%BD%D1%82%D1%80%D0%B0%D0%BA%D1%82%D0%B0.png?alt=media&amp;token=28316202-e6b6-47a7-aaa0-569ca5f4b678" alt=""><figcaption></figcaption></figure>

The following examples illustrate the required receiver behavior:

{% tabs %}
{% tab title="Node.js" %}

```javascript
import express from "express";

export function createCallbackRouter(crm) {
  const router = express.Router();

  router.post(
    "/docstudio/callback",
    express.json(),
    async (request, response) => {
      try {
        const { uuid, status } = request.body;

        if (!uuid || !status) {
          return response.sendStatus(400);
        }

        const contract =
          await crm.findByEnvelopeUuid(uuid);

        if (!contract) {
          return response.sendStatus(500);
        }

        if (status === "COMPLETED") {
          await crm.markContractCompleted(
            contract.id
          );
        }

        return response.sendStatus(200);
      } catch (error) {
        console.error(error);
        return response.sendStatus(500);
      }
    }
  );

  return router;
}
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

interface CrmClient
{
    public function findByEnvelopeUuid(
        string $uuid
    ): ?array;

    public function markContractCompleted(
        string $contractId
    ): void;
}

function handleCallback(CrmClient $crm): void
{
    try {
        $payload = json_decode(
            file_get_contents("php://input"),
            true,
            512,
            JSON_THROW_ON_ERROR
        );
    } catch (JsonException $error) {
        http_response_code(400);
        return;
    }

    $uuid = $payload["uuid"] ?? null;
    $status = $payload["status"] ?? null;

    if ($uuid === null || $status === null) {
        http_response_code(400);
        return;
    }

    $contract = $crm->findByEnvelopeUuid($uuid);

    if ($contract === null) {
        http_response_code(500);
        return;
    }

    if ($status === "COMPLETED") {
        $crm->markContractCompleted(
            $contract["id"]
        );
    }

    http_response_code(200);
}
```

{% endtab %}

{% tab title="Python" %}

```python
from flask import Blueprint, request

def create_callback_blueprint(crm):
    blueprint = Blueprint(
        "docstudio_callback",
        __name__,
    )

    @blueprint.post("/docstudio/callback")
    def callback():
        payload = request.get_json(
            silent=True
        )

        if not payload:
            return "", 400

        envelope_uuid = payload.get("uuid")
        status = payload.get("status")

        if not envelope_uuid or not status:
            return "", 400

        contract = (
            crm.find_by_envelope_uuid(
                envelope_uuid
            )
        )

        if not contract:
            return "", 500

        if status == "COMPLETED":
            crm.mark_contract_completed(
                contract["id"]
            )

        return "", 200

    return blueprint
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "sinatra/base"
require "json"

class DocStudioCallbackApp < Sinatra::Base
  set :crm, nil

  post "/docstudio/callback" do
    begin
      payload = JSON.parse(
        request.body.read
      )
    rescue JSON::ParserError
      halt 400
    end

    envelope_uuid = payload["uuid"]
    callback_status = payload["status"]

    if envelope_uuid.nil? ||
       callback_status.nil?
      halt 400
    end

    halt 500 if settings.crm.nil?

    contract =
      settings.crm.find_by_envelope_uuid(
        envelope_uuid
      )

    halt 500 unless contract

    if callback_status == "COMPLETED"
      settings.crm.mark_contract_completed(
        contract["id"]
      )
    end

    status 200
  end
end
```

{% endtab %}

{% tab title="Go" %}

```go
package callback

import (
	"encoding/json"
	"net/http"
)

type CallbackPayload struct {
	UUID   string `json:"uuid"`
	Status string `json:"status"`
}

type Contract struct {
	ID string
}

type CRM interface {
	FindByEnvelopeUUID(
		string,
	) (*Contract, error)

	MarkContractCompleted(
		string,
	) error
}

func Handler(crm CRM) http.HandlerFunc {
	return func(
		writer http.ResponseWriter,
		request *http.Request,
	) {
		if request.Method != http.MethodPost {
			http.Error(
				writer,
				"Method not allowed",
				http.StatusMethodNotAllowed,
			)
			return
		}

		var payload CallbackPayload

		if err := json.NewDecoder(
			request.Body,
		).Decode(&payload); err != nil {
			http.Error(
				writer,
				"Invalid callback payload",
				http.StatusBadRequest,
			)
			return
		}

		if payload.UUID == "" ||
			payload.Status == "" {
			http.Error(
				writer,
				"Missing callback fields",
				http.StatusBadRequest,
			)
			return
		}

		contract, err :=
			crm.FindByEnvelopeUUID(
				payload.UUID,
			)

		if err != nil || contract == nil {
			http.Error(
				writer,
				"Contract not found",
				http.StatusInternalServerError,
			)
			return
		}

		if payload.Status == "COMPLETED" {
			if err :=
				crm.MarkContractCompleted(
					contract.ID,
				); err != nil {
				http.Error(
					writer,
					"CRM update failed",
					http.StatusInternalServerError,
				)
				return
			}
		}

		writer.WriteHeader(http.StatusOK)
	}
}
```

{% endtab %}

{% tab title="Java" %}

```java
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CallbackController {
  private final CrmClient crm;

  public CallbackController(CrmClient crm) {
    this.crm = crm;
  }

  @PostMapping("/docstudio/callback")
  public ResponseEntity<Void> callback(
      @RequestBody CallbackPayload payload
  ) {
    if (payload.uuid() == null ||
        payload.status() == null) {
      return ResponseEntity.badRequest().build();
    }

    Contract contract =
        crm.findByEnvelopeUuid(payload.uuid());

    if (contract == null) {
      return ResponseEntity
          .internalServerError()
          .build();
    }

    if ("COMPLETED".equals(payload.status())) {
      crm.markContractCompleted(contract.id());
    }

    return ResponseEntity.ok().build();
  }

  public record CallbackPayload(
      String uuid,
      String status
  ) {}

  public record Contract(String id) {}

  public interface CrmClient {
    Contract findByEnvelopeUuid(
        String envelopeUuid
    );

    void markContractCompleted(
        String contractId
    );
  }
}
```

{% endtab %}

{% tab title=".NET" %}

```csharp
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;

public record CallbackPayload(
    string Uuid,
    string Status
);

public record Contract(string Id);

public interface ICrm
{
    Task<Contract?> FindByEnvelopeUuid(
        string envelopeUuid
    );

    Task MarkContractCompleted(
        string contractId
    );
}

public static class CallbackEndpoints
{
    public static void MapDocStudioCallback(
        this WebApplication app
    )
    {
        app.MapPost(
            "/docstudio/callback",
            async (
                CallbackPayload payload,
                ICrm crm
            ) =>
            {
                if (string.IsNullOrWhiteSpace(
                        payload.Uuid
                    ) ||
                    string.IsNullOrWhiteSpace(
                        payload.Status
                    ))
                {
                    return Results.BadRequest();
                }

                var contract =
                    await crm.FindByEnvelopeUuid(
                        payload.Uuid
                    );

                if (contract is null)
                {
                    return Results.StatusCode(500);
                }

                if (payload.Status == "COMPLETED")
                {
                    await crm.MarkContractCompleted(
                        contract.Id
                    );
                }

                return Results.Ok();
            }
        );
    }
}
```

{% endtab %}
{% endtabs %}

The receiving endpoint should handle repeated delivery safely. Before modifying a business record, use the envelope `uuid` and status to determine whether the same update has already been processed.

Returning `500` indicates that the callback could not be processed successfully. Because this is a `5xx` response, DocStudio retries the delivery according to the callback configuration.

### Manage callbacks

Listing and removing callbacks are management operations rather than steps in the callback setup workflow. Use them to inspect the current mailbox configuration or remove callbacks that are no longer needed.

#### List callbacks

Retrieve all callbacks configured for the current mailbox:

{% tabs %}
{% tab title="Node.js" %}

```javascript
const response = await fetch(
  "https://api.docstudio.com/api/v1/envelope/callback/list",
  {
    method: "GET",
    headers: {
      Authorization: "Bearer {token}",
      Mailbox: "{mailboxUuid}"
    }
  }
);

const body = await response.text();

if (!response.ok) {
  throw new Error(
    `Request failed: ${response.status}\n${body}`
  );
}

console.log(body);
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init(
    "https://api.docstudio.com/api/v1/envelope/callback/list"
);

curl_setopt_array($curl, [
    CURLOPT_HTTPGET => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer {token}",
        "Mailbox: {mailboxUuid}"
    ],
    CURLOPT_RETURNTRANSFER => true
]);

$body = curl_exec($curl);

if ($body === false) {
    throw new RuntimeException(curl_error($curl));
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException(
        "Request failed: {$status}\n{$body}"
    );
}

echo $body;
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

response = requests.get(
    "https://api.docstudio.com/api/v1/envelope/callback/list",
    headers={
        "Authorization": "Bearer {token}",
        "Mailbox": "{mailboxUuid}",
    },
    timeout=30,
)

response.raise_for_status()
print(response.text)
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "net/http"
require "uri"

uri = URI(
  "https://api.docstudio.com/api/v1/envelope/callback/list"
)

request = Net::HTTP::Get.new(uri)
request["Authorization"] = "Bearer {token}"
request["Mailbox"] = "{mailboxUuid}"

response = Net::HTTP.start(
  uri.hostname,
  uri.port,
  use_ssl: uri.scheme == "https"
) do |http|
  http.request(request)
end

unless response.is_a?(Net::HTTPSuccess)
  raise "Request failed: #{response.code}"
end

puts response.body
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	request, err := http.NewRequest(
		http.MethodGet,
		"https://api.docstudio.com/api/v1/envelope/callback/list",
		nil,
	)
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer {token}")
	request.Header.Set("Mailbox", "{mailboxUuid}")

	response, err := http.DefaultClient.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	body, err := io.ReadAll(response.Body)
	if err != nil {
		panic(err)
	}

	if response.StatusCode < 200 || response.StatusCode >= 300 {
		panic(fmt.Sprintf(
			"Request failed: %s\n%s",
			response.Status,
			body,
		))
	}

	fmt.Println(string(body))
}
```

{% endtab %}

{% tab title="Java" %}

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
  public static void main(String[] args) throws Exception {
    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create(
            "https://api.docstudio.com/api/v1/envelope/callback/list"
        ))
        .header("Authorization", "Bearer {token}")
        .header("Mailbox", "{mailboxUuid}")
        .GET()
        .build();

    HttpResponse<String> response =
        HttpClient.newHttpClient().send(
            request,
            HttpResponse.BodyHandlers.ofString()
        );

    if (response.statusCode() < 200 ||
        response.statusCode() >= 300) {
      throw new RuntimeException(
          "Request failed: " + response.statusCode()
          + "\n" + response.body()
      );
    }

    System.out.println(response.body());
  }
}
```

{% endtab %}

{% tab title=".NET" %}

```csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;

using var client = new HttpClient();

using var request = new HttpRequestMessage(
    HttpMethod.Get,
    "https://api.docstudio.com/api/v1/envelope/callback/list"
);

request.Headers.Authorization =
    new AuthenticationHeaderValue("Bearer", "{token}");
request.Headers.Add("Mailbox", "{mailboxUuid}");

using var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();

if (!response.IsSuccessStatusCode)
{
    throw new HttpRequestException(
        $"Request failed: {(int)response.StatusCode}\n{body}"
    );
}

Console.WriteLine(body);
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --request GET \
  --url 'https://api.docstudio.com/api/v1/envelope/callback/list' \
  --header 'Authorization: Bearer {token}' \
  --header 'Mailbox: {mailboxUuid}'
```

{% endtab %}
{% endtabs %}

The response contains an array of callback configurations. Each object includes the callback `id`, receiving URL, delivery settings, authentication type, and filter.

```json
[
  {
    "url": "{receiverUrl}",
    "retries": 3,
    "timeout": 5000,
    "successCode": 200,
    "id": "{callbackUuid}",
    "authType": "NONE",
    "filter": {
      "status": [
        "COMPLETED"
      ],
      "template": [
        "{templateUuid}"
      ]
    }
  }
]
```

Use the returned callback ID as `{callbackUuid}` when checking, testing, or removing a callback.

#### Remove a callback

Remove a callback that is no longer required:

{% tabs %}
{% tab title="Node.js" %}

```javascript
const response = await fetch(
  "https://api.docstudio.com/api/v1/envelope/callback/{callbackUuid}/remove",
  {
    method: "DELETE",
    headers: {
      Authorization: "Bearer {token}",
      Mailbox: "{mailboxUuid}"
    }
  }
);

const body = await response.text();

if (!response.ok) {
  throw new Error(
    `Request failed: ${response.status}\n${body}`
  );
}

if (body) {
  console.log(body);
}
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$curl = curl_init(
    "https://api.docstudio.com/api/v1/envelope/" .
    "callback/{callbackUuid}/remove"
);

curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => "DELETE",
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer {token}",
        "Mailbox: {mailboxUuid}"
    ],
    CURLOPT_RETURNTRANSFER => true
]);

$body = curl_exec($curl);

if ($body === false) {
    throw new RuntimeException(curl_error($curl));
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException(
        "Request failed: {$status}\n{$body}"
    );
}

if ($body !== "") {
    echo $body;
}
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

response = requests.delete(
    "https://api.docstudio.com/api/v1/envelope/"
    "callback/{callbackUuid}/remove",
    headers={
        "Authorization": "Bearer {token}",
        "Mailbox": "{mailboxUuid}",
    },
    timeout=30,
)

response.raise_for_status()

if response.text:
    print(response.text)
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require "net/http"
require "uri"

uri = URI(
  "https://api.docstudio.com/api/v1/envelope/" \
  "callback/{callbackUuid}/remove"
)

request = Net::HTTP::Delete.new(uri)
request["Authorization"] = "Bearer {token}"
request["Mailbox"] = "{mailboxUuid}"

response = Net::HTTP.start(
  uri.hostname,
  uri.port,
  use_ssl: uri.scheme == "https"
) do |http|
  http.request(request)
end

unless response.is_a?(Net::HTTPSuccess)
  raise "Request failed: #{response.code}"
end

puts response.body unless response.body.empty?
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	url := "https://api.docstudio.com/api/v1/envelope/" +
		"callback/{callbackUuid}/remove"

	request, err := http.NewRequest(
		http.MethodDelete,
		url,
		nil,
	)
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer {token}")
	request.Header.Set("Mailbox", "{mailboxUuid}")

	response, err := http.DefaultClient.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	body, err := io.ReadAll(response.Body)
	if err != nil {
		panic(err)
	}

	if response.StatusCode < 200 || response.StatusCode >= 300 {
		panic(fmt.Sprintf(
			"Request failed: %s\n%s",
			response.Status,
			body,
		))
	}

	if len(body) > 0 {
		fmt.Println(string(body))
	}
}
```

{% endtab %}

{% tab title="Java" %}

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

public class Main {
  public static void main(String[] args) throws Exception {
    String url =
        "https://api.docstudio.com/api/v1/envelope/"
        + "callback/{callbackUuid}/remove";

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create(url))
        .header("Authorization", "Bearer {token}")
        .header("Mailbox", "{mailboxUuid}")
        .DELETE()
        .build();

    HttpResponse<String> response =
        HttpClient.newHttpClient().send(
            request,
            HttpResponse.BodyHandlers.ofString()
        );

    if (response.statusCode() < 200 ||
        response.statusCode() >= 300) {
      throw new RuntimeException(
          "Request failed: " + response.statusCode()
          + "\n" + response.body()
      );
    }

    if (!response.body().isEmpty()) {
      System.out.println(response.body());
    }
  }
}
```

{% endtab %}

{% tab title=".NET" %}

```csharp
using System;
using System.Net.Http;
using System.Net.Http.Headers;

using var client = new HttpClient();

using var request = new HttpRequestMessage(
    HttpMethod.Delete,
    "https://api.docstudio.com/api/v1/envelope/" +
    "callback/{callbackUuid}/remove"
);

request.Headers.Authorization =
    new AuthenticationHeaderValue("Bearer", "{token}");
request.Headers.Add("Mailbox", "{mailboxUuid}");

using var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();

if (!response.IsSuccessStatusCode)
{
    throw new HttpRequestException(
        $"Request failed: {(int)response.StatusCode}\n{body}"
    );
}

if (!string.IsNullOrEmpty(body))
{
    Console.WriteLine(body);
}
```

{% endtab %}

{% tab title="cURL" %}

```bash
curl --request DELETE \
  --url 'https://api.docstudio.com/api/v1/envelope/callback/{callbackUuid}/remove' \
  --header 'Authorization: Bearer {token}' \
  --header 'Mailbox: {mailboxUuid}'
```

{% endtab %}
{% endtabs %}

A successful request returns `200 OK` without a response body. After the callback is removed, DocStudio no longer sends envelope data using that configuration.

### Troubleshooting

<table><thead><tr><th width="226">Problem</th><th>What to check</th></tr></thead><tbody><tr><td>The envelope does not match the callback</td><td>Call the filter-check endpoint and inspect <code>passed</code> and <code>failed</code>, compare the envelope with every configured filter criterion</td></tr><tr><td>The receiving endpoint returns <code>5xx</code></td><td>Check the receiving endpoint logs and processing errors; DocStudio retries delivery according to the configured <code>retries</code> value</td></tr><tr><td>The callback request times out</td><td>Make sure the receiving endpoint responds within the configured <code>timeout</code>, move long-running work to a background process when possible</td></tr><tr><td>The returned status does not equal <code>successCode</code></td><td>Configure the receiving endpoint to return the expected HTTP status after it accepts and processes the callback</td></tr><tr><td>The same update is processed more than once</td><td>Check the envelope <code>uuid</code> and status before modifying the external record ,repeated processing should not create duplicate changes</td></tr><tr><td>Unexpected envelopes trigger the callback</td><td>Review the configured filter and replace overly broad or incorrect criteria, use stable properties such as template, status, sender, form, or label</td></tr><tr><td>No envelopes trigger the callback</td><td>Confirm that at least one envelope matches every configured filter criterion , use the check endpoint before testing delivery</td></tr></tbody></table>

### Related topics

* [Envelope metadata](https://developers.docstudio.com/guides/envelope-metadata.md)
* [Check Envelope Status](https://developers.docstudio.com/api-reference/check-envelope-status.md)
* [XML payloads](https://developers.docstudio.com/guides/xml-payloads.md)
