Skip to main content
POST
/
keys
/
verify
Verify key
curl --request POST \
  --url https://api.datkey.dev/keys/verify \
  --header 'Content-Type: application/json' \
  --data '
{
  "api_id": "{api_id}",
  "key": "key_xxxxxxxxxxxxxxxx"
}
'
import requests

url = "https://api.datkey.dev/keys/verify"

payload = {
"api_id": "{api_id}",
"key": "key_xxxxxxxxxxxxxxxx"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({api_id: '{api_id}', key: 'key_xxxxxxxxxxxxxxxx'})
};

fetch('https://api.datkey.dev/keys/verify', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.datkey.dev/keys/verify",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'api_id' => '{api_id}',
'key' => 'key_xxxxxxxxxxxxxxxx'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.datkey.dev/keys/verify"

payload := strings.NewReader("{\n \"api_id\": \"{api_id}\",\n \"key\": \"key_xxxxxxxxxxxxxxxx\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.datkey.dev/keys/verify")
.header("Content-Type", "application/json")
.body("{\n \"api_id\": \"{api_id}\",\n \"key\": \"key_xxxxxxxxxxxxxxxx\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.datkey.dev/keys/verify")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"api_id\": \"{api_id}\",\n \"key\": \"key_xxxxxxxxxxxxxxxx\"\n}"

response = http.request(request)
puts response.read_body
{
  "valid": true,
  "key": {
    "id": "<id>",
    "name": "ACME INC",
    "key": "flox_sk_05ad2bf*********",
    "prefix": "flox_sk",
    "length": 16,
    "verifications": 5,
    "verification_limit": 90,
    "expires_at": 1733237153,
    "meta": null,
    "created_at": "2023-12-05T11:31:23.000000Z",
    "updated_at": "2023-12-05T13:03:24.000000Z"
  }
}
{
"valid": false,
"status": "EXPIRED"
}

Headers

x-api-key
string

your workspace API key

Body

application/json
api_id
string
required

API ID from your dashboard

Example:

"{api_id}"

key
string
required

The generated API key

Example:

"key_xxxxxxxxxxxxxxxx"

Response

OK

valid
boolean

Whether the key is valid or not. A key could be invalid for a number of reasons, for example if it has expired or has no more verifications left

Example:

true

status
enum<string>

If the key status is false this field will be set to the reason why it is invalid. Possible values are:

  • USAGE_EXCEEDED: the key has exceeded its validation limit
  • EXPIRED: the key has expired,
Available options:
EXPIRED,
USAGE_EXCEEDED
api_id
string

The ID of the API the key belongs to

Example:

"{api_id}"

name
string

The name assigned to the key

Example:

"{api_name}"

prefix
string

The prefix assigned to the key

Example:

"prefix"

length
integer
default:16

The length assigned to the key

Required range: 16 <= x <= 255
meta
object

extra details you passed via the meta attribute

Example:
{ "user_id": "123456" }
expires_at
integer<int64>

Unix timestamp of when the key expires, returns null when not set

verification_limit
integer<int64>

maximum verification allowed for this key, returns null when not set