Delete an Aggregate
delete
https://api.serialized.io
/aggregates/{aggregateType}/{aggregateId}
Delete an aggregate

Example

This example requests a delete token for deleting a specific order aggregate
cURL
Java
C#
Node
1
curl -i \
2
--header "Serialized-Access-Key: <YOUR_ACCESS_KEY>" \
3
--header "Serialized-Secret-Access-Key: <YOUR_SECRET_ACCESS_KEY>" \
4
-X DELETE https://api.serialized.io/aggregates/order/d28bae0e-6f46-4c88-8935-b6e2c87ae4af
Copied!
1
import javax.ws.rs.client.Client;
2
import javax.ws.rs.client.ClientBuilder;
3
4
Client client = ClientBuilder.newClient();
5
URI apiRoot = URI.create("https://api.serialized.io");
6
7
Map response = client.target(apiRoot)
8
.path("aggregates")
9
.path("order")
10
.path("99415be8-6819-4470-860c-c2933558d8d3")
11
.request()
12
.header("Serialized-Access-Key", "<YOUR_ACCESS_KEY>")
13
.header("Serialized-Secret-Access-Key", "<YOUR_SECRET_ACCESS_KEY>")
14
.delete(Map.class);
15
16
String deleteToken = (String) response.get("deleteToken");
Copied!
1
using RestSharp;
2
using System;
3
4
var client = new RestClient("https://api.serialized.io");
5
6
var request = new RestRequest("aggregates/order/{aggregateId}", Method.DELETE)
7
.AddUrlSegment("aggregateId", "99415be8-6819-4470-860c-c2933558d8d3")
8
.AddHeader("Serialized-Access-Key", "<YOUR_ACCESS_KEY>")
9
.AddHeader("Serialized-Secret-Access-Key", "<YOUR_SECRET_ACCESS_KEY>");
10
11
var response = client.Execute<Dictionary<string, Object>>(request);
12
var deleteToken = response.Data["deleteToken"]
Copied!
1
const axios = require("axios");
2
3
const client = axios.create({
4
baseURL: "https://api.serialized.io",
5
headers: {"Serialized-Access-Key": "<YOUR_ACCESS_KEY>"},
6
headers: {"Serialized-Secret-Access-Key": "<YOUR_SECRET_ACCESS_KEY>"}
7
});
8
9
client.delete("aggregates/order/99415be8-6819-4470-860c-c2933558d8d3")
10
.then(function (response) {
11
const deleteToken = response.data.deleteToken;
12
// Use deleteToken
13
})
14
.catch(function (error) {
15
// Handle error
16
});
Copied!

Permanently deleting the aggregate using the delete token

This example permanently deletes an aggregate using a delete token that was returned in the response to the preceding delete request.
This is a permanent request that cannot be undone. If you need to be able to restore this data in any way you must back it up on your side before executing the deletion.
cURL
Java
C#
Node
1
curl -i \
2
--header "Serialized-Access-Key: <YOUR_ACCESS_KEY>" \
3
--header "Serialized-Secret-Access-Key: <YOUR_SECRET_ACCESS_KEY>" \
4
-X DELETE https://api.serialized.io/aggregates/order/d28bae0e-6f46-4c88-8935-b6e2c87ae4af?deleteToken=12c3780f-2dcb-340f-5532-5693be83f21c
Copied!
1
Response delete = client.target(apiRoot)
2
.path("aggregates")
3
.path("order")
4
.path("99415be8-6819-4470-860c-c2933558d8d3")
5
.queryParam("deleteToken", deleteToken)
6
.request()
7
.header("Serialized-Access-Key", "<YOUR_ACCESS_KEY>")
8
.header("Serialized-Secret-Access-Key", "<YOUR_SECRET_ACCESS_KEY>")
9
.delete();
Copied!
1
var request = new RestRequest("aggregates/order/{aggregateId}", Method.DELETE)
2
.AddUrlSegment("aggregateId", "99415be8-6819-4470-860c-c2933558d8d3")
3
.AddHeader("Serialized-Access-Key", "<YOUR_ACCESS_KEY>")
4
.AddHeader("Serialized-Secret-Access-Key", "<YOUR_SECRET_ACCESS_KEY>")
5
.AddQueryParameter("deleteToken", deleteToken);
6
7
var response = client.Execute<Dictionary<string, Object>>(request);
Copied!
1
const requestConfig = {
2
params: {
3
deleteToken: deleteToken
4
}
5
};
6
7
client.delete("aggregates/order/99415be8-6819-4470-860c-c2933558d8d3", requestConfig)
8
.then(function (response) {
9
// Handle response
10
})
11
.catch(function (error) {
12
// Handle error
13
});
Copied!