How-to

Use your API key

Use the API key that I Need A Database provisions when you create a project.

Get the key

  1. Sign up and create your first project.
  2. Copy the API key from the project-created screen.
  3. Regenerate it from the project dashboard if you need a new secret.
  4. Store it as a server-side secret.

Use the key

Send the key in an Authorization header with each project API request.

curl
curl https://ineedadatabase.com/api/v1/projects/proj_123/collections \
  -H "Authorization: Bearer inadb_..."

How authentication works

I Need A Database currently uses one full-access bearer API key per project. The full key is returned once when the project is created or regenerated.

header
Authorization: Bearer inadb_...

Regenerating a key immediately revokes the previous one, so update your deployments before removing the old secret from your systems.

Keep it secret, keep it safe

Remember that this key has full access to everything in the project, including deleting data. Use it from your server, worker, or automation job rather than exposing it in browser-side code.

Use a server proxy

For frontend apps, call your own server route or serverless function from the browser. That route should read the API key from environment variables and call I Need A Database server-side.

server route
export async function GET() {
  const response = await fetch(
    `https://ineedadatabase.com/api/v1/projects/${process.env.INEEDADATABASE_PROJECT_ID}/collections/recipes/documents`,
    {
      headers: {
        Authorization: `Bearer ${process.env.INEEDADATABASE_API_KEY}`
      }
    }
  );

  return Response.json(await response.json(), { status: response.status });
}