GitGuardian API (1.0.2)

Download OpenAPI specification:Download

Introduction

Whether you want to build a complete integration with your software development workflow or simply want to test GitGuardian's policy break detection on any text content, you can use our API.

  • The base url for the latest version is api.gitguardian.com/v1 over HTTPS.
  • All data is sent and received as JSON by default.
  • All timestamps returned are ISO-8601 compliant, example:
    2020-03-16T04:46:00+00:00 # for date-time

Authentication

The GitGuardian API uses API keys to authenticate requests.

You need to create an account before getting started in order to get an API key.

Your API key can be created and revoked from the API section of your dashboard.

Your API key must kept private and should neither be embedded directly in the code nor versioned in Git. (Please do not push GitGuardian's API keys to public GitHub repositories ^^).

Beware your API keys can expire and can be revoked.

Use /v1/health to check the validity of your token if needed.

curl -H "Authorization: Token ${TOKEN}" \
  https://api.gitguardian.com/v1/health

API Key

Usage: Token <API Key> in authorization header.

Security Scheme Type HTTP
HTTP Authorization Scheme bearer
Bearer format "Token <API Key>"

Scanning

Use GitGuardian's brain at your leisure.

Scanning API allows you to scan any content you want using GitGuardian's secret detection algorithms.

Content Scan

Scan provided document content for policy breaks. Request

Authorizations:
Request Body schema: application/json
filename
string <= 256 characters
document
required
string

Responses

200

Successful Scan

400

Invalid data

401

Invalid API key

403

Quota limit reached

503

API under maintenance

post/v1/scan
https://api.gitguardian.com/v1/scan

Request samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "filename": ".env",
  • "document": "\nimport urllib.request\nurl = 'http://jen_barber:correcthorsebatterystaple@cake.gitguardian.com/isreal.json'\nresponse = urllib.request.urlopen(url)\nconsume(response.read())\n"
}

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "policy_break_count": 2,
  • "policies":
    [
    ],
  • "policy_breaks":
    [
    ]
}

Multiple Content Scan

Scan provided document contents for policy breaks. Multiple documents are returned by the same index order. Request body shouldn't exceed 2MB and individual documents shouldn't exceed 1MB.

Authorizations:
Request Body schema: application/json
Array
filename
string <= 256 characters
document
required
string

Responses

200

Successful Scan

400

Invalid data

401

Invalid API key

403

Quota limit reached

503

API under maintenance

post/v1/multiscan
https://api.gitguardian.com/v1/multiscan

Request samples

Content type
application/json
Copy
Expand all Collapse all
[
  • {
    },
  • {
    }
]

Response samples

Content type
application/json
Copy
Expand all Collapse all
[
  • {
    },
  • {
    }
]

Health Check

Check the status of the API and your token without spending your quota.

Authorizations:

Responses

200

API on and key valid response

401

Invalid API key

503

API under maintenance

get/v1/health
https://api.gitguardian.com/v1/health

Request samples

Copy
curl --request GET \
    --url https://api.gitguardian.com/v1/health \
    --header 'authorization: Token <Insert API Key>'

Response samples

Content type
application/json
Copy
Expand all Collapse all
{
  • "detail": "Valid API key."
}