API
Authentication

API Authentication

All requests to the Trycolors API must be authenticated using an API key. This ensures that only authorized users can access the API and helps us maintain the security and integrity of our service.

Obtaining an API Key

To get an API key:

  1. Sign in to your Trycolors account at trycolors.com/signin (opens in a new tab).
  2. Navigate to your account settings.
  3. Look for the "API Keys" section.
  4. Click on "Generate API Key".
  5. Copy and securely store your new API key.

Using Your API Key

To authenticate your requests, include your API key in the X-API-KEY header of each request:

X-API-KEY: your_api_key_here

Example Request

Here's an example of how to include your API key in a request using JavaScript and fetch:

const apiKey = 'your_api_key_here';
const endpoint = 'https://api.trycolors.com/v1/mix-colors';
 
fetch(endpoint, {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-KEY': apiKey
  },
  body: JSON.stringify({
    // request payload
  })
})
.then(response => {
  if (!response.ok) {
    throw new Error(`HTTP error! status: ${response.status}`);
  }
  return response.json();
})
.then(data => {
  console.log(data);
})
.catch(error => {
  console.error('Error:', error.message);
});

Security Best Practices

  1. Never share your API key publicly or commit it to version control systems.
  2. Use environment variables or secure secret management systems to store your API key.
  3. Rotate your API key periodically for enhanced security.
  4. If you suspect your API key has been compromised, generate a new one immediately and revoke the old one.

For any issues with authentication or if you need to revoke and regenerate your API key, please contact our support team.