Delete a Microsoft Graph credential
Delete a Microsoft Graph app-only credential. Woodpecker blocks deletion when the credential is used by an active Microsoft mailbox.
Request
Endpoint
DELETE https://api.woodpecker.co/rest/v2/mailboxes/microsoft/credentials/{credential_id}
Headers
x-api-key: {YOUR_API_KEY}
For details on how to authenticate your requests, please see the authentication guide.
Request samples
Delete a credential
- cURL
- Python
- Java
- Node.js
- PHP
curl --request DELETE \
--url "https://api.woodpecker.co/rest/v2/mailboxes/microsoft/credentials/{credential_id}" \
--header "x-api-key: {YOUR_API_KEY}"
import requests
def delete_microsoft_graph_credential(credential_id):
url = f"https://api.woodpecker.co/rest/v2/mailboxes/microsoft/credentials/{credential_id}"
headers = {
"x-api-key": "{YOUR_API_KEY}"
}
response = requests.delete(url, headers=headers)
if response.status_code == 204:
print("Credential deleted.")
else:
print("Request failed:", response.status_code, response.text)
if __name__ == "__main__":
delete_microsoft_graph_credential(22334455)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class WoodpeckerApiClient {
private static final String API_KEY = "{YOUR_API_KEY}";
public static void main(String[] args) {
deleteMicrosoftGraphCredential(22334455);
}
public static void deleteMicrosoftGraphCredential(int credentialId) {
try {
String url = "https://api.woodpecker.co/rest/v2/mailboxes/microsoft/credentials/" + credentialId;
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("x-api-key", API_KEY)
.DELETE()
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
if (response.statusCode() == 204) {
System.out.println("Credential deleted.");
} else {
System.err.println("Request failed: " + response.statusCode());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
const axios = require("axios");
async function deleteMicrosoftGraphCredential(credentialId) {
const url = `https://api.woodpecker.co/rest/v2/mailboxes/microsoft/credentials/${credentialId}`;
const headers = {
"x-api-key": "{YOUR_API_KEY}"
};
try {
const response = await axios.delete(url, { headers });
if (response.status === 204) {
console.log("Credential deleted.");
} else {
console.error("Request failed:", response.status);
}
} catch (error) {
console.error("Request error:", error.response?.status || error.message);
}
}
deleteMicrosoftGraphCredential(22334455);
<?php
require 'vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
$credentialId = 22334455;
$client = new Client([
'base_uri' => 'https://api.woodpecker.co/rest/v2/',
'headers' => [
'x-api-key' => getenv('WOODPECKER_API_KEY'),
],
]);
try {
$response = $client->delete("mailboxes/microsoft/credentials/{$credentialId}");
echo $response->getStatusCode(), "\n";
} catch (RequestException $e) {
echo "Error: ", $e->getMessage(), "\n";
if ($e->hasResponse()) {
echo $e->getResponse()->getBody(), "\n";
}
}
Response
Response examples
- 204
- 401
- 404
- 422
- 500
The credential was deleted.
Status: 204
Body: none
An issue with authorization. Please review the authorization guide.
{
"title": "Unauthorized",
"status": 401,
"detail": "Invalid api key",
"timestamp": "2025-03-05 17:57:00"
}
Body schema
| Field | Type | Description |
|---|---|---|
title | string | A short title describing the error. |
status | integer | The HTTP status code. |
detail | string | A detailed message explaining the error. |
timestamp | string | The timestamp when the error occurred, YYYY-MM-DD HH:MM:SS UTC. |
Please review the request URL.
{
"title": "Not Found",
"status": 404,
"detail": "Requested resource does not exist",
"timestamp": "2025-03-05 17:57:00"
}
Body schema
| Field | Type | Description |
|---|---|---|
title | string | A short title describing the error |
status | integer | The HTTP status code |
detail | string | A detailed message explaining the error |
timestamp | string | The timestamp when the error occurred, YYYY-MM-DD HH:MM:SS UTC |
Invalid request or malformed request syntax. The request can also fail when the credential cannot be deleted.
{
"message": "MICROSOFT_GRAPH_CREDENTIAL_IN_USE"
}
Body schema
| Field | Type | Description |
|---|---|---|
message | string | Validation error message. Possible values:
|
Unexpected error, please try again later
{
"title": "Internal server error",
"status": 500,
"detail": "An unexpected error has occurred. Please try again later.",
"timestamp": "2025-03-05 17:57:00"
}
Body schema
| Field | Type | Description |
|---|---|---|
title | string | A short title describing the error |
status | integer | The HTTP status code |
detail | string | A detailed message explaining the error |
timestamp | string | The timestamp when the error occurred, YYYY-MM-DD HH:MM:SS UTC |