For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
HUMAN DashboardHUMAN WebsiteRequest a Demo
Product GuidesEnforcer GuidesMobile SDKAPI ReferenceCustomer support
Product GuidesEnforcer GuidesMobile SDKAPI ReferenceCustomer support
  • User guides
    • About the Applications API
    • Getting started
    • Authentication
    • Quick reference
  • Account Defender API
  • Bot Defender API
  • Credential Intelligence API
  • Code Defender API
    • Code Examples
  • Enforce API
  • PCI DSS API
LogoLogo
Login
Login
HUMAN DashboardHUMAN WebsiteRequest a Demo
Code Defender API

Code examples

Was this page helpful?
Previous

Enforce an HTTP request

Next
Built with

You can leverage the Code Defender API to retrieve a variety of data about your application. Below are examples of how you can use the API for different scenarios.

Get all incidents in the past month for all applications

  1. Request the account’s overall data. This returns an object with different account data. One of the fields, named applications, holds all the applications that were ever enabled on Code Defender.
1curl --request GET \
2 --url https://api-gw.perimeterx.com/v1/account-settings \
3 --header 'accept: application/json'
  1. With the array from Step 1, you can extract all app_ids.
1const appIds = accountSettingsresult.applications.map(application => application.app_id);
  1. After obtaining all relevant app Ids, you can easily request all incidents using start and end timestamps from the past month. This example shows timestamps for the full month of April 2023.
1const incidentsPerAppId = Promise.All(
2 appIds.map(appId =>
3 fetch(
4 `https://api-gw.perimeterx.com/v1/incidents?appId=${appId}&tld=example.com&from=1680307200000&to=1682899199000&take=20&skip=0`, headers: { Authentication: 'Bearer ' }
5 )
6 )
7)