Delete API Key

Delete an API key from your shard node by sending a DELETE request to the specified endpoint with the API key value in the request body.

DELETE /api-key

Deletes an API key with the specified value

Important Notes

  • • Requires an API key with write access to the root path
  • • The API key value to delete must be provided in the request body as JSON
  • • Use your shard node URL and your API key

Headers

Header Type Required Description
x-user-api-key string Yes Your authentication API key with root write access
Content-Type application/json Yes MIME type for JSON request body

Request Body

Field Type Required Description
value string Yes The API key value to delete

Example Request

func DeleteAPIKey(value string) {

	url := fmt.Sprintf("%s/api-key?value=%s", SHARD_NODE_URL, url.QueryEscape(value))
	req, err := http.NewRequest(http.MethodDelete, url,nil)
	if err != nil {
		panic(fmt.Errorf("could not create DELETE request to /api-key: %w", err))
	}

	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("x-user-api-key", API_KEY)

	client := http.DefaultClient
	resp, err := client.Do(req)
	if err != nil {
		panic(fmt.Errorf("Response error from shard:: %w", err))
	}
	defer resp.Body.Close()

	if resp.StatusCode != http.StatusOK {
		body, _ := io.ReadAll(resp.Body)
		panic(fmt.Sprintf("Delete API key failed with status %d: %s", resp.StatusCode, string(body)))
	}

}
async function deleteAPIKey(value: string): Promise<void> {
    const url = `${SHARD_NODE_URL}/api-key?value=${encodeURIComponent(value)}`;
    const res = await fetch(url, {
        method: 'DELETE',
        headers: {
            'Content-Type': 'application/json',
            'x-user-api-key': API_KEY
        },
    });

    if (res.status !== 200) {
        const body = await res.text();
        throw new Error(`Delete API key failed with status ${res.status}: ${body}`);
    }
}

Response Status Codes

Code Status Description
200 Success API key deleted successfully
400 Bad Request Invalid request parameters or body
401 Unauthorized Invalid or missing API key
5xx Server Error Internal server error - check response body for details