> ## Documentation Index
> Fetch the complete documentation index at: https://chainpatrol.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Obtener tiempo hasta la detección

> How long threats were already live before the earliest automated detection of the asset, for any organization. Broken down by asset type, for distinct assets this organization blocked in the date range that are still blocked today. The clock runs from when the asset was first seen live to its earliest automated detection; a human report does not stop it. Each median is a minimum.

## Descripción general

Obtén cuánto tiempo llevaban online las amenazas antes de que la automatización de ChainPatrol las detectara
por primera vez, por tipo de **asset** (activo digital: URL, dirección, perfil, app, etc.). Abarca los assets distintos que tu organización bloqueó en un
rango de fechas y que siguen bloqueados hoy.

> [!NOTE]
>
> Este endpoint está restringido por el feature flag `time-to-detection-chart`, que se
> habilita por organización. Si el flag no está habilitado para tu organización, la API
> devuelve un error 403 Forbidden. Contacta a ChainPatrol para habilitar el acceso.

```bash theme={null}
curl --request POST \
  --url https://app.chainpatrol.io/api/v2/metrics/time-to-detection \
  --header 'Content-Type: application/json' \
  --header 'X-API-KEY: <api-key>' \
  --data '{
    "slug": "your-org",
    "startDate": "2026-08-01",
    "endDate": "2026-10-31"
  }'
```

## Cuerpo de la solicitud

| Campo | Tipo | Obligatorio | Descripción |
| - | - | - | - |
| `slug` | `string` | ✅ Sí | Slug de la organización. |
| `startDate` | `string` | ❌ No | Solo assets bloqueados en esta fecha o después. Un valor de solo fecha (`YYYY-MM-DD`) empieza a la medianoche UTC. |
| `endDate` | `string` | ❌ No | Solo assets bloqueados en esta fecha o antes. Un valor de solo fecha abarca todo el día en UTC. |
| `brandIds` | `number[]` | ❌ No | Solo assets que pertenecen a estas marcas. |
| `countryCodes` | `string[]` | ❌ No | Solo assets escaneados desde estos países (códigos ISO 3166-1 alpha-2). |

## Cómo se mide

El reloj corre desde la primera vez que alguien vio el asset online hasta su primera detección
automatizada, para cualquier organización. Un reporte hecho por una persona no detiene el reloj, ni siquiera
si es tuyo.

`byAssetType` tiene una entrada por tipo de asset, ordenadas de mayor a menor cantidad de bloqueos:

| Campo | Descripción |
| - | - |
| `blocked` | Assets distintos de este tipo bloqueados en el rango y que siguen bloqueados hoy. |
| `withEvidence` | De esos, cuántos entran en la mediana: tienen una fecha aceptada en la que estaban online y una detección automatizada posterior a ella. |
| `medianDaysAtLeast` | Mediana de días que el asset estuvo online antes de ser detectado. `null` cuando `withEvidence` es 0. |

La mediana siempre es un mínimo: la fecha en la que estaba online es la primera vez que alguien vio el asset,
y puede que haya estado online antes de eso. Para URLs y páginas solo cuenta una fecha en la que se vio
el sitio sirviendo contenido, así que la fecha de registro de un dominio nunca entra en el cálculo.


## OpenAPI

````yaml POST /metrics/time-to-detection
openapi: 3.0.3
info:
  title: ChainPatrol External API - OpenAPI 3.0
  description: ChainPatrol External API documentation
  version: 2.0.0
servers:
  - url: https://app.chainpatrol.io/api/v2
security: []
tags:
  - name: asset
  - name: report
  - name: dark-web
externalDocs:
  url: https://chainpatrol.com/docs
paths:
  /metrics/time-to-detection:
    post:
      tags:
        - metrics
      summary: Get organization time to detection by asset type
      description: >-
        How long threats were already live before the earliest automated
        detection of the asset, for any organization. Broken down by asset type,
        for distinct assets this organization blocked in the date range that are
        still blocked today. The clock runs from when the asset was first seen
        live to its earliest automated detection; a human report does not stop
        it. Each median is a minimum.
      operationId: metricsTimeToDetection
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                slug:
                  type: string
                  minLength: 1
                  description: Organization slug
                startDate:
                  type: string
                  description: >-
                    Only include assets blocked on or after this date. A
                    date-only value (YYYY-MM-DD) starts at midnight UTC
                endDate:
                  type: string
                  description: >-
                    Only include assets blocked on or before this date. A
                    date-only value (YYYY-MM-DD) covers the whole day in UTC;
                    pass a full timestamp for a precise cut-off
                brandIds:
                  type: array
                  items:
                    type: integer
                    minimum: 0
                    exclusiveMinimum: true
                  description: Only include assets belonging to these brands
                countryCodes:
                  type: array
                  items:
                    type: string
                    minLength: 2
                    maxLength: 2
                  description: >-
                    Only include assets scanned from these ISO 3166-1 alpha-2
                    countries
              required:
                - slug
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  byAssetType:
                    type: array
                    items:
                      type: object
                      properties:
                        assetType:
                          type: string
                          enum:
                            - URL
                            - PAGE
                            - ADDRESS
                            - DISCORD
                            - LINKEDIN
                            - TWITTER
                            - FACEBOOK
                            - YOUTUBE
                            - REDDIT
                            - TELEGRAM
                            - GOOGLE_APP_STORE
                            - APPLE_APP_STORE
                            - AMAZON_APP_STORE
                            - MICROSOFT_APP_STORE
                            - TIKTOK
                            - INSTAGRAM
                            - THREADS
                            - MEDIUM
                            - CHROME_WEB_STORE
                            - MOZILLA_ADDONS
                            - OPERA_ADDONS
                            - EMAIL
                            - PATREON
                            - OPENSEA
                            - FARCASTER
                            - IPFS
                            - GOOGLE_FORM
                            - WHATSAPP
                            - DISCORD_USER
                            - QUORA
                            - GITHUB
                            - TEACHABLE
                            - SUBSTACK
                            - DEBANK
                            - TAWK_TO
                            - JOTFORM
                            - PRIMAL
                            - BLUESKY
                            - SNAPCHAT
                            - DESO
                            - PINTEREST
                            - FLICKR
                            - GALXE
                            - VELOG
                            - NPM
                            - PYPI
                            - HEX
                            - DOCKER_HUB
                            - VOCAL_MEDIA
                            - TECKFINE
                            - TENDERLY
                            - HACKMD
                            - ETSY
                            - ZAZZLE
                            - BASENAME
                            - BILIBILI_TV
                            - VIMEO
                            - DAILYMOTION
                            - PHONE_NUMBER
                            - SLACK
                            - CALENDLY
                            - NGROK
                            - RARIBLE
                            - RUST_PACKAGE
                            - FLATHUB
                            - VIDLII
                            - VEVIOZ
                            - ISSUU
                            - SOUNDCLOUD
                            - ZAPPER
                            - REDNOTE
                            - SAMSUNG_APP_STORE
                            - HUAWEI_APP_STORE
                            - XIAOMI_APP_STORE
                            - TENCENT_APP_STORE
                            - OPPO_APP_STORE
                            - VIVO_APP_STORE
                            - F_DROID
                            - GOOGLE_AD
                            - BING_AD
                            - TWITCH
                            - BEHANCE
                            - ZORA
                            - META_AD
                            - SIGNAL
                            - DEVIANTART
                            - BANDCAMP
                            - ARCHIVE_ORG
                            - FIVE_HUNDRED_PX
                            - LUMA
                            - SMARTMONEYMATCH
                            - APK_GOLD
                            - GLASSDOOR
                            - PUMP_FUN
                            - TUMBLR
                            - MASTODON
                          description: Asset type that was blocked
                        blocked:
                          type: number
                          description: >-
                            Distinct assets of this type the organization
                            blocked within the date range that are still blocked
                            today
                        withEvidence:
                          type: number
                          description: >-
                            Of those, how many enter the median: an accepted
                            live date and an automated detection after it. A
                            live date with no detection result does not count,
                            and a human report is not a detection
                        medianDaysAtLeast:
                          type: number
                          nullable: true
                          description: >-
                            Median days the asset was already live before the
                            earliest automated detection of that asset, for any
                            organization. Always a minimum, because the live
                            date is the first time anyone saw the asset. Null
                            when withEvidence is 0
                      required:
                        - assetType
                        - blocked
                        - withEvidence
                        - medianDaysAtLeast
                    description: >-
                      Time to Detection, one entry per asset type this
                      organization blocked in the range, descending by number
                      blocked. The clock stops at the earliest automated
                      detection of the asset for any organization, not at this
                      organization's report. Assets that do not enter
                      withEvidence are left out of the median. For URL and page
                      assets only an observed-serving date counts, so a domain
                      registration date never enters the number
                required:
                  - byAssetType
        '400':
          description: Invalid input data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.BAD_REQUEST'
        '401':
          description: Authorization not provided
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.UNAUTHORIZED'
        '403':
          description: Insufficient access
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.FORBIDDEN'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/error.INTERNAL_SERVER_ERROR'
      security:
        - ApiKey: []
components:
  schemas:
    error.BAD_REQUEST:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Invalid input data
        code:
          type: string
          description: The error code
          example: BAD_REQUEST
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Invalid input data error (400)
      description: The error information
      example:
        code: BAD_REQUEST
        message: Invalid input data
        issues: []
    error.UNAUTHORIZED:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Authorization not provided
        code:
          type: string
          description: The error code
          example: UNAUTHORIZED
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Authorization not provided error (401)
      description: The error information
      example:
        code: UNAUTHORIZED
        message: Authorization not provided
        issues: []
    error.FORBIDDEN:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Insufficient access
        code:
          type: string
          description: The error code
          example: FORBIDDEN
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Insufficient access error (403)
      description: The error information
      example:
        code: FORBIDDEN
        message: Insufficient access
        issues: []
    error.INTERNAL_SERVER_ERROR:
      type: object
      properties:
        message:
          type: string
          description: The error message
          example: Internal server error
        code:
          type: string
          description: The error code
          example: INTERNAL_SERVER_ERROR
        issues:
          type: array
          items:
            type: object
            properties:
              message:
                type: string
            required:
              - message
          description: An array of issues that were responsible for the error
          example: []
      required:
        - message
        - code
      title: Internal server error error (500)
      description: The error information
      example:
        code: INTERNAL_SERVER_ERROR
        message: Internal server error
        issues: []
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: X-API-KEY
      description: >-
        Your API key. This is required by most endpoints to access our API
        programatically. Reach out to us at
        [support@chainpatrol.io](mailto:support@chainpatrol.io?subject=Re:%20API%20Key%20for%20SDK&body=Company:%20%0AName:%20%0APurpose:%20)
        to get an API key for your use.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.