Skip to main content

API Key Authentication

This API uses API Key authentication to authorize requests. You need to include your API key in the request header under the x-api-key field to access protected resources.

How to Authenticate with an API Key

To authenticate with the API, you must pass your API key in the header of your HTTP request. The header key should be x-api-key, and the value should be your unique API key.

Header Example

x-api-key: your_api_key_here

Example Request

Here’s an example of a typical HTTP request with the API key in the header:

Example using curl

curl -X GET "https://api.trigify.io/v1/your-endpoint" \
     -H "x-api-key: your_api_key_here"

Example using JavaScript (Fetch API)

fetch("https://api.trigify.io/v1/your-endpoint", {
  method: "GET",
  headers: {
    "x-api-key": "your_api_key_here",
  },
})
  .then((response) => response.json())
  .then((data) => console.log(data))
  .catch((error) => console.error("Error:", error));

Example using Python (requests library)

import requests

url = "https://api.trigify.io/v1/your-endpoint"
headers = {
    "x-api-key": "your_api_key_here"
}

response = requests.get(url, headers=headers)
print(response.json())

Error Responses

If your API key is missing or invalid, the API will return an error response with an HTTP status code of 401 Unauthorized.

Example Error Response

{
  "message": "Unauthorized",
  "error": "Invalid or missing API key"
}

Managing Your API Key

  • You can obtain your API key by booking a call.
  • Keep your API key secure. Do not share it publicly or include it in client-side code.

Conclusion

By adding the x-api-key header to your requests, you can securely authenticate and interact with the API. Always make sure to store your API key in a secure location and rotate it periodically if needed. If you have any questions, please contact our support team at [email protected].

This page gives clear instructions, code examples, and error handling for how to use API key authentication with your API.