You can interact with the API through HTTP requests from any language.

Authentication

All API requests should include your API key in an Authorization HTTP header as follows:

Authorization: Bearer API_KEY

You can obtain your API key from the settings.

Keep your API key confidential! Avoid sharing it with others or exposing it in client-side code (such as browsers or apps). For production requests, ensure they are routed through your backend server, where the API key can be securely accessed from an environment variable or key management service.

Making a request

You can paste the command below into your terminal to run your first API request. Make sure to replace API_KEY with your secret API key, TEAM_ID with your team ID, and VERIFIER_ID with the verifier ID.

curl --request POST \
  --url https://api.naviml.com/v1/TEAM_ID/verify \
  --header 'Authorization: Bearer API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "messages": [
    {
      "content": "Hello World",
      "role": "user"
    }
  ],
  "verifiers": [
    {
      "id": "VERIFIER_ID",
      "parameters": {
        "threshold": 0.5
      },
      "type": "policy-verifier"
    }
  ],
  "explain": true
}'

You should get a response that is similar to this:

{
  "request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "action": "allow",
  "result": {
    "verifiers": [
      {
        "id": "VERIFIER_ID",
        "result": "Compliant",
        "explanation": {
          "text": "The content is compliant with the policy because it does not contain any contradictions to existing policies.",
        },
        "action": "allow",
        "details": null,
        "usage": {
          "prompt_tokens": 123,
          "completion_tokens": 123,
          "total_tokens": 123
        }
      }
    ],
    "action": "allow"
  }
}

API errors

The API uses standard HTTP status codes to indicate the success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that failed given the information provided (e.g., a required parameter was omitted), and codes in the 5xx range indicate an error with the API server.

CodeTitleCommon reasonCommon resolution
400Bad RequestThe request could not be understood or was missing required parameters.Check if your request follows API documentation
401UnauthorizedAuthentication failed or user does not have permissions for the desired action.Check if API key is valid or resource belongs to the right team.
403ForbiddenAuthentication succeeded but authenticated user does not have access to the resource.Check if API key has required permissions or resource belongs to the right team.
404Not FoundThe requested resource could not be found.Check if the requested resource ID is correct.
429Rate limit exceededYou are hitting the rate limitPace your requests. Our current limit is 60 requests per minute.
500Internal Server ErrorAn error occurred on the server.There is unexpected error on server side. Contact our support for this.
503Service UnavailableThe service is not available.Our server might be overloaded or unavailble. Contact our support for this.