Files
prowler/examples/api/api-key-bash.ipynb
T

25 KiB

Prowler API Examples

1. Create a New API Key

Follow the instructions in the Prowler documentation to create a new API key.

2. Set the API Key

Create a .envrc file in this directory with your API key:

export PROWLER_API_KEY=your-api-key-here

Then load the environment variable:

In [5]:
%%bash
source .envrc
echo "API key loaded from .envrc file"
API key loaded from .envrc file

3. Use the API Key

List Providers

In [6]:
%%bash
source .envrc

curl -X GET 'https://api.dev.prowler.com/api/v1/providers' \
  -H "Authorization: Api-Key ${PROWLER_API_KEY}" \
  -H 'Content-Type: application/vnd.api+json' \
  | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  5647  100  5647    0     0   1467      0  0:00:03  0:00:03 --:--:--  1467
{
  "links": {
    "first": "https://api.dev.prowler.com/api/v1/providers?page%5Bnumber%5D=1",
    "last": "https://api.dev.prowler.com/api/v1/providers?page%5Bnumber%5D=2",
    "next": "https://api.dev.prowler.com/api/v1/providers?page%5Bnumber%5D=2",
    "prev": null
  },
  "data": [
    {
      "type": "providers",
      "id": "50af9045-023a-4390-b2a6-7e08bb482c7e",
      "attributes": {
        "inserted_at": "2025-10-21T14:13:18.925063Z",
        "updated_at": "2025-10-21T15:09:54.262401Z",
        "provider": "m365",
        "uid": "prowler.com",
        "alias": null,
        "connection": {
          "connected": true,
          "last_checked_at": "2025-10-21T15:09:54.257607Z"
        }
      },
      "relationships": {
        "secret": {
          "data": {
            "type": "provider-secrets",
            "id": "d7308e68-ab2e-4c22-b388-e5005a5fc57d"
          }
        },
        "provider_groups": {
          "meta": {
            "count": 0
          },
          "data": []
        }
      },
      "links": {
        "self": "https://api.dev.prowler.com/api/v1/providers/50af9045-023a-4390-b2a6-7e08bb482c7e"
      }
    },
    {
      "type": "providers",
      "id": "e3bf0cb7-791f-42fd-9d19-b6d7db72290a",
      "attributes": {
        "inserted_at": "2025-10-13T09:56:07.101323Z",
        "updated_at": "2025-10-13T10:43:55.963669Z",
        "provider": "gcp",
        "uid": "empty-project-465413",
        "alias": null,
        "connection": {
          "connected": true,
          "last_checked_at": "2025-10-13T10:43:55.959115Z"
        }
      },
      "relationships": {
        "secret": {
          "data": {
            "type": "provider-secrets",
            "id": "52f16eeb-14d6-46b8-9c97-a283e5386ac2"
          }
        },
        "provider_groups": {
          "meta": {
            "count": 0
          },
          "data": []
        }
      },
      "links": {
        "self": "https://api.dev.prowler.com/api/v1/providers/e3bf0cb7-791f-42fd-9d19-b6d7db72290a"
      }
    },
    {
      "type": "providers",
      "id": "53237f83-5c4d-45e4-82f3-aa9da4bbbe00",
      "attributes": {
        "inserted_at": "2025-10-07T13:57:15.884120Z",
        "updated_at": "2025-10-07T13:57:15.884136Z",
        "provider": "gcp",
        "uid": "test-posthog",
        "alias": null,
        "connection": {
          "connected": null,
          "last_checked_at": null
        }
      },
      "relationships": {
        "secret": {
          "data": null
        },
        "provider_groups": {
          "meta": {
            "count": 0
          },
          "data": []
        }
      },
      "links": {
        "self": "https://api.dev.prowler.com/api/v1/providers/53237f83-5c4d-45e4-82f3-aa9da4bbbe00"
      }
    },
    {
      "type": "providers",
      "id": "8c776ad5-d2ff-4574-bd41-753dbbd35bec",
      "attributes": {
        "inserted_at": "2025-10-01T14:18:04.872628Z",
        "updated_at": "2025-10-01T14:18:04.872644Z",
        "provider": "aws",
        "uid": "123456789122",
        "alias": null,
        "connection": {
          "connected": null,
          "last_checked_at": null
        }
      },
      "relationships": {
        "secret": {
          "data": {
            "type": "provider-secrets",
            "id": "b56191d1-328e-42ee-a0f3-1422bf3dca9f"
          }
        },
        "provider_groups": {
          "meta": {
            "count": 0
          },
          "data": []
        }
      },
      "links": {
        "self": "https://api.dev.prowler.com/api/v1/providers/8c776ad5-d2ff-4574-bd41-753dbbd35bec"
      }
    },
    {
      "type": "providers",
      "id": "09f9949d-e801-4865-803d-51c8ee9c70f5",
      "attributes": {
        "inserted_at": "2025-08-28T06:57:15.819206Z",
        "updated_at": "2025-09-25T14:33:14.763507Z",
        "provider": "github",
        "uid": "dTroop3r",
        "alias": "GH using App",
        "connection": {
          "connected": true,
          "last_checked_at": "2025-09-25T14:33:14.757995Z"
        }
      },
      "relationships": {
        "secret": {
          "data": {
            "type": "provider-secrets",
            "id": "6ade14ed-0113-4b42-955c-c0159315821a"
          }
        },
        "provider_groups": {
          "meta": {
            "count": 0
          },
          "data": []
        }
      },
      "links": {
        "self": "https://api.dev.prowler.com/api/v1/providers/09f9949d-e801-4865-803d-51c8ee9c70f5"
      }
    },
    {
      "type": "providers",
      "id": "d664cb20-3cc8-403d-9d62-0773c61642d7",
      "attributes": {
        "inserted_at": "2025-08-28T06:48:40.344590Z",
        "updated_at": "2025-08-28T09:53:07.955423Z",
        "provider": "github",
        "uid": "PieceOfM1nd",
        "alias": "PieceOfM1nd (org)",
        "connection": {
          "connected": true,
          "last_checked_at": "2025-08-28T09:53:07.949871Z"
        }
      },
      "relationships": {
        "secret": {
          "data": {
            "type": "provider-secrets",
            "id": "ca7d8494-069b-4388-9d02-3310b96c6fbd"
          }
        },
        "provider_groups": {
          "meta": {
            "count": 0
          },
          "data": []
        }
      },
      "links": {
        "self": "https://api.dev.prowler.com/api/v1/providers/d664cb20-3cc8-403d-9d62-0773c61642d7"
      }
    },
    {
      "type": "providers",
      "id": "00acd090-ad97-4182-91d2-f279502fb3eb",
      "attributes": {
        "inserted_at": "2025-08-21T16:35:31.030729Z",
        "updated_at": "2025-08-21T17:14:25.890660Z",
        "provider": "aws",
        "uid": "123456789111",
        "alias": "Test role bug",
        "connection": {
          "connected": null,
          "last_checked_at": null
        }
      },
      "relationships": {
        "secret": {
          "data": {
            "type": "provider-secrets",
            "id": "332bea53-6381-484d-83ed-ca1ccc52dd76"
          }
        },
        "provider_groups": {
          "meta": {
            "count": 0
          },
          "data": []
        }
      },
      "links": {
        "self": "https://api.dev.prowler.com/api/v1/providers/00acd090-ad97-4182-91d2-f279502fb3eb"
      }
    },
    {
      "type": "providers",
      "id": "dcf3bc9c-102c-4f47-9753-3732a70601d7",
      "attributes": {
        "inserted_at": "2025-08-21T16:21:18.013721Z",
        "updated_at": "2025-08-21T16:21:18.013738Z",
        "provider": "aws",
        "uid": "123456789012",
        "alias": null,
        "connection": {
          "connected": null,
          "last_checked_at": null
        }
      },
      "relationships": {
        "secret": {
          "data": null
        },
        "provider_groups": {
          "meta": {
            "count": 0
          },
          "data": []
        }
      },
      "links": {
        "self": "https://api.dev.prowler.com/api/v1/providers/dcf3bc9c-102c-4f47-9753-3732a70601d7"
      }
    },
    {
      "type": "providers",
      "id": "2642ea99-cd32-463c-a7e9-8b7791f8f7e5",
      "attributes": {
        "inserted_at": "2025-08-09T07:54:03.128579Z",
        "updated_at": "2025-08-09T07:54:03.128594Z",
        "provider": "github",
        "uid": "pedrooot",
        "alias": null,
        "connection": {
          "connected": null,
          "last_checked_at": null
        }
      },
      "relationships": {
        "secret": {
          "data": null
        },
        "provider_groups": {
          "meta": {
            "count": 0
          },
          "data": []
        }
      },
      "links": {
        "self": "https://api.dev.prowler.com/api/v1/providers/2642ea99-cd32-463c-a7e9-8b7791f8f7e5"
      }
    },
    {
      "type": "providers",
      "id": "bc7a6295-f706-4361-855d-2352829b6668",
      "attributes": {
        "inserted_at": "2025-08-04T12:36:34.699122Z",
        "updated_at": "2025-10-21T12:38:42.660182Z",
        "provider": "kubernetes",
        "uid": "arn:aws:eks:eu-west-1:106908755756:cluster/test",
        "alias": "EKS Dev",
        "connection": {
          "connected": false,
          "last_checked_at": "2025-10-21T12:38:42.655786Z"
        }
      },
      "relationships": {
        "secret": {
          "data": {
            "type": "provider-secrets",
            "id": "52471ba2-27de-4570-a762-aee33bc3f44c"
          }
        },
        "provider_groups": {
          "meta": {
            "count": 0
          },
          "data": []
        }
      },
      "links": {
        "self": "https://api.dev.prowler.com/api/v1/providers/bc7a6295-f706-4361-855d-2352829b6668"
      }
    }
  ],
  "meta": {
    "pagination": {
      "page": 1,
      "pages": 2,
      "count": 16
    },
    "version": "v1"
  }
}

Get One Critical Finding from Latest Scan

In [7]:
%%bash
source .envrc

curl -X GET 'https://api.dev.prowler.com/api/v1/findings/latest?filter%5Bseverity__in%5D=critical&page%5Bsize%5D=1' \
  -H "Authorization: Api-Key ${PROWLER_API_KEY}" \
  -H 'Content-Type: application/vnd.api+json' \
  | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3170  100  3170    0     0   2041      0  0:00:01  0:00:01 --:--:--  2041
{
  "links": {
    "first": "https://api.dev.prowler.com/api/v1/findings/latest?filter%5Bseverity__in%5D=critical&page%5Bnumber%5D=1&page%5Bsize%5D=1",
    "last": "https://api.dev.prowler.com/api/v1/findings/latest?filter%5Bseverity__in%5D=critical&page%5Bnumber%5D=946&page%5Bsize%5D=1",
    "next": "https://api.dev.prowler.com/api/v1/findings/latest?filter%5Bseverity__in%5D=critical&page%5Bnumber%5D=2&page%5Bsize%5D=1",
    "prev": null
  },
  "data": [
    {
      "type": "findings",
      "id": "019a0753-1e4b-7229-bb7d-91eab8fc0f4f",
      "attributes": {
        "uid": "prowler-m365-teams_unmanaged_communication_disabled-f4dffefa-083f-4e9e-91e0-5d1e04f4b72b-global-Teams User Settings",
        "delta": "new",
        "status": "PASS",
        "status_extended": "Teams users cannot communicate with unmanaged users.",
        "severity": "critical",
        "check_id": "teams_unmanaged_communication_disabled",
        "check_metadata": {
          "risk": "Allowing communication with unmanaged Microsoft Teams users increases the risk of targeted attacks such as phishing, malware distribution (e.g., DarkGate), and exploitation techniques like GIFShell and username enumeration. Unmanaged accounts are easier for threat actors to create and use as attack vectors.",
          "notes": "",
          "checkid": "teams_unmanaged_communication_disabled",
          "provider": "m365",
          "severity": "critical",
          "checktype": [],
          "dependson": [],
          "relatedto": [],
          "categories": [
            "e3"
          ],
          "checktitle": "Ensure unmanaged communication is disabled.",
          "compliance": [],
          "relatedurl": "https://learn.microsoft.com/en-us/powershell/module/teams/set-cstenantfederationconfiguration?view=teams-ps",
          "description": "Ensure unmanaged communication is disabled in Teams admin center.",
          "remediation": {
            "code": {
              "cli": "Set-CsTenantFederationConfiguration -AllowTeamsConsumer $false",
              "other": "1. Navigate to Microsoft Teams admin center https://admin.teams.microsoft.com/. 2. Click to expand Users select External access. 3. Scroll to Teams accounts not managed by an organization. 4. Set People in my organization can communicate with Teams users whose accounts aren't managed by an organization to Off. 5. Click Save.",
              "nativeiac": "",
              "terraform": ""
            },
            "recommendation": {
              "url": "https://learn.microsoft.com/en-us/powershell/module/teams/set-cstenantfederationconfiguration?view=teams-ps",
              "text": "Disable communication with Teams users whose accounts aren't managed by an organization by setting 'People in my organization can communicate with Teams users whose accounts aren't managed by an organization' to Off. This helps prevent unauthorized or risky external interactions."
            }
          },
          "servicename": "teams",
          "checkaliases": [],
          "resourcetype": "Teams Settings",
          "additionalurls": [],
          "subservicename": "",
          "resourceidtemplate": ""
        },
        "raw_result": {},
        "inserted_at": "2025-10-21T15:11:19.115828Z",
        "updated_at": "2025-10-21T15:11:19.120405Z",
        "first_seen_at": "2025-10-21T15:11:19.113770Z",
        "muted": false,
        "muted_reason": null
      },
      "relationships": {
        "scan": {
          "data": {
            "type": "scans",
            "id": "019a074f-e8c1-74b9-84e6-95a821f7ac30"
          }
        },
        "resources": {
          "meta": {
            "count": 1
          },
          "data": [
            {
              "type": "resources",
              "id": "3455f95f-f985-48c4-ac34-d22baac19aa3"
            }
          ]
        }
      },
      "links": {
        "self": "https://api.dev.prowler.com/api/v1/findings/019a0753-1e4b-7229-bb7d-91eab8fc0f4f"
      }
    }
  ],
  "meta": {
    "pagination": {
      "page": 1,
      "pages": 946,
      "count": 946
    },
    "version": "v1"
  }
}