POST
/
public
/
getOrganizationMetrics
curl --request POST \
  --url https://app.chainpatrol.io/api/v2/public/getOrganizationMetrics \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: <api-key>' \
  --data '{
  "organizationSlug": "<string>",
  "startDate": "<string>",
  "endDate": "<string>"
}'
{
  "metrics": {
    "reportsCount": 123,
    "threatsBlockedCount": 123,
    "threatsBlockedByAssetType": [
      {
        "assetType": "<string>",
        "count": 123
      }
    ],
    "domainsBlockedCount": 123,
    "totalTakedownsFiledCount": 123,
    "totalTakedownsCompletedCount": 123
  }
}

This API requires an API key with appropriate permissions. See API Key Documentation for more details.

Quick Start

Authentication

Include your API key in the Authorization header:

Authorization: Bearer your_api_key

Example Request

curl -X POST 'https://api.chainpatrol.io/public/getOrganizationMetrics' \
  -H 'Authorization: Bearer your_api_key' \
  -H 'Content-Type: application/json' \
  -d '{
    "organizationSlug": "your-org",
    "startDate": "2024-01-01T00:00:00Z",
    "endDate": "2024-03-01T00:00:00Z"
  }'

Access Control

The API enforces strict access control based on your API key type:

  1. Organization API Keys:

    • Can only access metrics for their associated organization
    • Must match the organizationSlug exactly
    • Example: An API key for “acme-org” can only query metrics for “acme-org”
  2. User API Keys:

    • Can access metrics for any organization where the user is a member
    • Requires the user to be an active member of the queried organization
    • Example: A user who is a member of both “acme-org” and “beta-org” can query metrics for both organizations

If you attempt to query an organization without proper permissions, you will receive a 403 Forbidden error with the message: “You do not have permission to access metrics for this organization”

Example Implementation

async function fetchOrganizationMetrics(organizationSlug, startDate, endDate) {
  const response = await fetch(
    "https://api.chainpatrol.io/public/getOrganizationMetrics",
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization: "Bearer YOUR_API_KEY_HERE",
      },
      body: JSON.stringify({
        organizationSlug,
        startDate,
        endDate,
      }),
    }
  );
  return response.json();
}

// Example usage
fetchOrganizationMetrics(
  "your-org",
  "2024-01-01T00:00:00Z",
  "2024-03-01T00:00:00Z"
)
  .then((data) => console.log("Metrics:", data))
  .catch((error) => console.error("Error fetching metrics:", error));

API Details

Request Parameters

ParameterTypeRequiredDescription
organizationSlugstringYesOrganization slug to query
startDateDateNoStart date for metrics (default: all time)
endDateDateNoEnd date for metrics (default: current date)

Response Format

{
  metrics: {
    reportsCount: number; // Total number of reports
    threatsBlockedCount: number; // Total number of threats blocked
    threatsBlockedByAssetType: Array<{
      // Threats blocked grouped by asset type
      assetType: string;
      count: number;
    }>;
    domainsBlockedCount: number; // Number of domains blocked
    totalTakedownsFiledCount: number; // Total number of takedowns filed
    totalTakedownsCompletedCount: number; // Total number of completed takedowns
  }
}

Error Handling

Status CodeDescription
401 UnauthorizedInvalid or missing API key
403 ForbiddenAPI key does not have permission to query the requested organization
500 Internal Server ErrorServer error occurred while processing the request

Notes

  • If no date range is provided, metrics will be returned for all time
  • The API only returns metrics for a single organization per request
  • Organization API keys can only access metrics for their associated organization
  • User API keys can access metrics for any organization where the user is a member
  • To query multiple organizations, you must use a user API key and ensure the user is a member of all organizations you wish to query

Authorizations

X-API-KEY
string
header
required

Your API key. This is required by most endpoints to access our API programatically. Reach out to us at support@chainpatrol.io to get an API key for your use.

Body

application/json
organizationSlug
string
required
startDate
string
endDate
string

Response

200
application/json
Successful response
metrics
object
required