Complete API Reference

ZKAuth API Reference

Complete REST API documentation for ZKAuth. All endpoints, authentication methods, and response formats.

Base URL

All API requests should be made to the following base URL

Production API

text
https://zkp-engine-main-1.vercel.app

All API endpoints are relative to this base URL

Authentication Methods

Choose the authentication method that works best for your use case

API key header

Include your project key in the x-api-key header

text
x-api-key: zka_live_your_api_key

Test key

Use zka_test keys for sandbox requests

text
x-api-key: zka_test_your_api_key

Session JWT

User routes also require the login session token

text
Authorization: Bearer eyJ...

API Endpoints

Complete list of available API endpoints

POST
API key
/api/v1/auth/register

Register a new user with ZK commitment

Request Body

json
{
  "email": "string",
  "password": "string",
  "deviceInfo": "object"
}

Response

json
{
  "success": "boolean",
  "data": "{ userId, deviceId, emailVerified }"
}
POST
API key
/api/v1/auth/login

Authenticate user with ZK proof

Request Body

json
{
  "email": "string",
  "password": "string",
  "deviceInfo": "object"
}

Response

json
{
  "success": "boolean",
  "data": "{ user, session }"
}
POST
API key + session JWT
/api/v1/auth/me

Verify session token

Request Body

json
{
  "token": "string"
}

Response

json
{
  "valid": "boolean",
  "user": "User object"
}
POST
API key + session JWT
/api/v1/auth/logout

Invalidate session

Request Body

json
{
  "token": "string"
}

Response

json
{
  "success": "boolean"
}
GET
API key + session JWT
/api/v1/auth/me

Get user profile

Request Body

json
"None"

Response

json
{
  "user": "User object"
}
PUT
API key + session JWT
/api/v1/auth/me

Update user profile

Request Body

json
{
  "name": "string",
  "avatar": "string"
}

Response

json
{
  "success": "boolean",
  "user": "User object"
}

Code Examples

See how to use the API in different languages

cURL

bash
curl -X POST https://zkp-engine-main-1.vercel.app/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -H "x-api-key: zka_live_your_api_key" \
  -d '{
    "email": "user@example.com",
    "password": "secure_password",
    "deviceInfo": {
      "deviceName": "Chrome on MacBook",
      "deviceType": "desktop"
    }
  }'

JavaScript

javascript
const response = await fetch('https://zkp-engine-main-1.vercel.app/api/v1/auth/register', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-api-key': 'zka_live_your_api_key'
  },
  body: JSON.stringify({
    email: 'user@example.com',
    password: 'secure_password',
    deviceInfo: {
      deviceName: 'Chrome on MacBook',
      deviceType: 'desktop'
    }
  })
});

const data = await response.json();
console.log(data);

Python

python
import requests

response = requests.post(
    'https://zkp-engine-main-1.vercel.app/api/v1/auth/register',
    headers={
        'Content-Type': 'application/json',
        'x-api-key': 'zka_live_your_api_key'
    },
    json={
        'email': 'user@example.com',
        'password': 'secure_password',
        'deviceInfo': {
            'deviceName': 'Chrome on MacBook',
            'deviceType': 'desktop'
        }
    }
)

data = response.json()
print(data)

Go

go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

func main() {
    payload := map[string]string{
        "email":    "user@example.com",
        "password": "secure_password",
    }

    jsonData, _ := json.Marshal(payload)

    req, _ := http.NewRequest("POST",
        "https://zkp-engine-main-1.vercel.app/api/v1/auth/register",
        bytes.NewBuffer(jsonData))

    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("x-api-key", "zka_live_your_api_key")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()

    var result map[string]interface{}
    json.NewDecoder(resp.Body).Decode(&result)
    fmt.Println(result)
}

Rust

rust
use reqwest;
use serde_json::{json, Value};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = reqwest::Client::new();

    let response = client
        .post("https://zkp-engine-main-1.vercel.app/api/v1/auth/register")
        .header("Content-Type", "application/json")
        .header("x-api-key", "zka_live_your_api_key")
        .json(&json!({
            "email": "user@example.com",
            "password": "secure_password"
        }))
        .send()
        .await?;

    let data: Value = response.json().await?;
    println!("{:?}", data);

    Ok(())
}

Vue.js

vue
<template>
  <div>
    <button @click="signUp" :disabled="loading">
      {{ loading ? 'Signing up...' : 'Sign Up' }}
    </button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loading: false
    }
  },
  methods: {
    async signUp() {
      this.loading = true;
      try {
        const response = await fetch('https://zkp-engine-main-1.vercel.app/api/v1/auth/register', {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json',
            'x-api-key': 'zka_live_your_api_key'
          },
          body: JSON.stringify({
            email: 'user@example.com',
            password: 'secure_password'
          })
        });

        const data = await response.json();
        console.log('User created:', data);
      } catch (error) {
        console.error('Sign up failed:', error);
      } finally {
        this.loading = false;
      }
    }
  }
}
</script>

Ready to Integrate?

Start building secure applications with ZKAuth today.