Walkthrough: Deleting traces in bulk using the Cryptosense Analyzer API
Aim
This walkthrough will guide you through the process of deleting a trace using the Cryptosense Analyzer v2 API. Then, the guide will demonstrate how to leverage GraphQL to delete traces in bulk.
Prerequisites
Before you begin, make sure that you have the following pieces of information available:
- Your Cryptosense API key.
- This key can be found at the API page of the analyzer.
- If you do not have API access enabled, then the link above will return a 404 error. To enable API access, please contact support.
- A trace to upload.
- For instructions on generating a trace, please see our user manual for the Java Tracer.
- In the instructions below, the name of the trace is assumed to be
trace_name.cst.gz
.
As well as the information above, you will need a client to interact with API. In this walkthrough, we use the open-source curl HTTP client, which is available for most platforms.
Delete a Trace
Traces can be deleted using the GraphQL deleteTrace
mutation.
curl \
--header 'API-KEY: <Cryptosense API Key>' \
--header 'Content-Type: application/json' \
--data-raw '{"query": "mutation { deleteTrace(input: {traceId: "<trace ID>"}){ clientMutationId }}"}' \
https://analyzer.cryptosense.com/api/v2
Delete Traces in Bulk
It is also possible to send multiple mutations in a single GraphQL query. Combining with the previous example, this enables bulk deletion of traces on the Cryptosense Platform. Here is an example, deleting two traces with a single curl call:
curl \
--header 'API-KEY: <Cryptosense API Key>' \
--header 'Content-Type: application/json' \
--data-raw '{"query": "mutation { d0: deleteTrace(input: {traceId: "<trace ID 1>"}){ clientMutationId } d1: deleteTrace(input {traceId: "<trace ID 2>"}){ clientMutationId }}"}' \
https://analyzer.cryptosense.com/api/v2
The d0
and d1
names here can be changed to be any valid GraphQL query label. The
return value will contain the response for each individual deletion request. One failed
delete does not impact the others. For example, in the example above, if d0
where to
succeed, while d1
where to fail, the return value would be:
{
"errors": [
{
"message": "<error message>",
"locations": [{"line": 6, "column": 3}],
"path": ["d1"]
}
],
"data": {
"d0": {
"clientMutationId": null
},
"d1": null
}
}