Skip to main content

API Keys & Programmatic Access

Access your chat interfaces programmatically using API keys and our v1 API. Perfect for integrating Axie Studio into your applications, websites, or automated workflows.

API Version

All Axie Studio APIs use v1 versioning. All endpoints are prefixed with /api/v1/ to ensure stability and future compatibility.

Who is this for?
  • Developers: Integrate chat into your apps
  • Businesses: Automate customer support
  • Power Users: Build custom workflows
  • Integration Teams: Connect to existing systems

🎯 What are API Keys?

API keys let you send messages to your chat interfaces from anywhere - your website, mobile app, or automation scripts.

Think of it like this:

Your App → API Key → Your Chat Interface → AI Response

Real-World Examples:

  • 💬 Add a chatbot to your website
  • 📱 Build a mobile app with AI support
  • 🤖 Automate customer support workflows
  • 🔗 Connect to Zapier, Make, or other tools

🚀 Quick Start (5 Minutes)

Step 1: Create an API Key

  1. Go to Dashboard → API Keys
  2. Click "+ Create API Key"
  3. Fill in the details:
    • API Key Name: e.g., "Production API", "Test Key"
    • Chat Interface: Select which chat interface this key can access
  4. Click "Create API Key"
Create API Key
Create API Key Dialog
What You'll See

A dialog will appear asking for:

  • API Key Name: Give it a memorable name (e.g., "Production API", "Mobile App")
  • Chat Interface: Select which chat interface this key can access
Save Your Key!

Your API key will only be shown ONCE. Copy it immediately and store it securely. You won't be able to see it again!

Step 2: Make Your First API Call

// Simple example - Send a message
const response = await fetch('https://public.axiestudio.se/api/v1/chat/your-chat-slug', {
method: 'POST',
headers: {
'Authorization': 'Bearer axie_your_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: 'Hello! How can you help me?'
})
});

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

That's it! You just sent your first message via API. 🎉


📋 Understanding API Keys

How API Keys Work

┌─────────────┐
│ API Key │ ← You create this
└──────┬──────┘

↓ Tied to ONE chat interface
┌─────────────────────┐
│ Chat Interface │ ← Your chatbot
└──────┬──────────────┘

↓ Optionally connected to
┌─────────────────────┐
│ Knowledge Base │ ← Your documents (optional)
└─────────────────────┘

Key Concepts

1. One Key = One Chat Interface

  • Each API key is tied to one specific chat interface
  • Want to access multiple chat interfaces? Create multiple keys
  • This keeps your access secure and organized

2. Chat Interface Connection

  • Your API key accesses the chat interface you selected
  • If that chat interface has a knowledge base, you get AI answers from your documents
  • If no knowledge base, it uses the chat interface's default settings

3. Security

  • API keys are hashed and encrypted
  • Only you see the full key (once, when created)
  • Keys can be deactivated without deleting them
  • Optional expiration dates for extra security

💻 Using Your API Key

Basic Message

Send a simple message and get a response:

const response = await fetch('https://public.axiestudio.se/api/v1/chat/your-slug', {
method: 'POST',
headers: {
'Authorization': 'Bearer axie_your_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: 'What are your business hours?'
})
});

const data = await response.json();

if (data.success) {
console.log('Answer:', data.message);
console.log('Sources:', data.sources); // If knowledge base is used
}

Conversation Memory

Keep track of conversations using sessionId:

// First message
const response1 = await fetch('https://public.axiestudio.se/api/v1/chat/your-slug', {
method: 'POST',
headers: {
'Authorization': 'Bearer axie_your_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: 'My name is John',
sessionId: 'user_123_session' // ← Remember this!
})
});

const data1 = await response1.json();
console.log(data1.sessionId); // Save this for next message

// Second message (AI remembers the conversation)
const response2 = await fetch('https://public.axiestudio.se/api/v1/chat/your-slug', {
method: 'POST',
headers: {
'Authorization': 'Bearer axie_your_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: 'What is my name?',
sessionId: 'user_123_session' // ← Same session ID
})
});

const data2 = await response2.json();
console.log(data2.message); // "Your name is John"

Why use sessionId?

  • ✅ AI remembers previous messages
  • ✅ Better context for answers
  • ✅ More natural conversations
  • ✅ Track individual users

🎨 Real-World Examples

Example 1: Website Chatbot

Add a chatbot to your website:

<!DOCTYPE html>
<html>
<head>
<title>My Website Chat</title>
</head>
<body>
<div id="chat-container">
<div id="messages"></div>
<input type="text" id="user-input" placeholder="Ask a question...">
<button onclick="sendMessage()">Send</button>
</div>

<script>
const API_KEY = 'axie_your_key_here';
const CHAT_SLUG = 'your-chat-slug';
const SESSION_ID = 'user_' + Date.now();

async function sendMessage() {
const input = document.getElementById('user-input');
const message = input.value;

// Show user message
addMessage('You: ' + message);
input.value = '';

// Send to API
const response = await fetch(`https://public.axiestudio.se/api/v1/chat/${CHAT_SLUG}`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: message,
sessionId: SESSION_ID
})
});

const data = await response.json();

// Show AI response
if (data.success) {
addMessage('AI: ' + data.message);
}
}

function addMessage(text) {
const messages = document.getElementById('messages');
const div = document.createElement('div');
div.textContent = text;
messages.appendChild(div);
}
</script>
</body>
</html>

Example 2: Customer Support Automation

Automatically respond to support emails:

// Node.js example
const axios = require('axios');

async function handleSupportEmail(email) {
const response = await axios.post(
'https://public.axiestudio.se/api/v1/chat/support-bot',
{
message: email.body,
sessionId: `email_${email.id}`
},
{
headers: {
'Authorization': 'Bearer axie_your_key',
'Content-Type': 'application/json'
}
}
);

if (response.data.success) {
// Send AI response back to customer
await sendEmail(email.from, response.data.message);

// Log sources if knowledge base was used
if (response.data.sources && response.data.sources.length > 0) {
console.log('Answer based on:', response.data.sources);
}
}
}

Example 3: Mobile App Integration

// React Native example
import React, { useState } from 'react';
import { View, TextInput, Button, Text } from 'react-native';

function ChatScreen() {
const [message, setMessage] = useState('');
const [response, setResponse] = useState('');
const [sessionId] = useState(`mobile_${Date.now()}`);

const sendMessage = async () => {
const result = await fetch('https://public.axiestudio.se/api/v1/chat/mobile-support', {
method: 'POST',
headers: {
'Authorization': 'Bearer axie_your_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: message,
sessionId: sessionId
})
});

const data = await result.json();

if (data.success) {
setResponse(data.message);
}
};

return (
<View>
<TextInput
value={message}
onChangeText={setMessage}
placeholder="Ask a question..."
/>
<Button title="Send" onPress={sendMessage} />
<Text>{response}</Text>
</View>
);
}

🔐 Security Best Practices

✅ DO:

1. Keep Keys Secret

// ✅ GOOD - Use environment variables
const API_KEY = process.env.AXIE_API_KEY;

// ❌ BAD - Don't hardcode in code
const API_KEY = 'axie_abc123...'; // Never do this!

2. Use Different Keys for Different Environments

Production API Key  → Live website
Test API Key → Development/testing
Staging API Key → Staging environment

3. Set Expiration Dates

  • For temporary integrations
  • For contractors/external developers
  • For testing purposes

4. Monitor Usage

  • Check "Last Used" date regularly
  • Review usage count
  • Deactivate unused keys

❌ DON'T:

1. Don't Share Keys

  • Never commit to Git
  • Don't share in Slack/email
  • Don't include in screenshots

2. Don't Use Same Key Everywhere

  • Create separate keys for each app
  • Easier to track and revoke

3. Don't Ignore Inactive Keys

  • Delete or deactivate unused keys
  • Review keys monthly

📊 API Response Format

Success Response

{
"success": true,
"message": "AI response text here",
"sources": [
{
"content": "Relevant document excerpt...",
"metadata": {
"fileName": "user_guide.pdf",
"page": 5
},
"score": 0.95
}
],
"usage": {
"prompt_tokens": 150,
"completion_tokens": 75,
"total_tokens": 225
},
"sessionId": "user_123_session",
"toolCalls": [],
"formConfig": null
}

Fields Explained:

  • message: The AI's response to your question
  • sources: Documents used (if knowledge base is connected)
  • usage: Token consumption for billing/tracking
  • sessionId: Use this in next message for conversation memory
  • toolCalls: Any tools the AI used (e.g., sending emails)
  • formConfig: If AI requested a form to be filled

Error Response

{
"error": "Invalid API key",
"message": "The provided API key is invalid or has been revoked"
}

Common Errors:

ErrorMeaningSolution
Invalid API keyKey doesn't exist or is wrongCheck your key
API key expiredKey has passed expiration dateCreate a new key
Access deniedKey doesn't have access to this chatCheck chat interface selection
Rate limit exceededToo many requestsWait and retry
Chat interface not foundSlug is wrong or inactiveCheck your chat slug

⚡ Rate Limits

To ensure fair usage, API keys have rate limits:

LimitValue
Requests per hour1,000
Requests per minute60
Message length10,000 characters

What happens if you exceed limits?

  • You'll get a 429 error
  • Wait for the reset time
  • Consider upgrading your plan

Tips to stay within limits:

  • Cache responses when possible
  • Batch similar questions
  • Use sessionId to reduce context tokens

🔧 Troubleshooting

"Invalid API key" Error

Problem: Your API key is not recognized

Solutions:

  1. Check you copied the entire key (starts with axie_)
  2. Verify the key is still active in dashboard
  3. Make sure it hasn't expired
  4. Try creating a new key

"Access denied" Error

Problem: API key doesn't have access to this chat interface

Solutions:

  1. Check which chat interface the key is tied to
  2. Verify you're using the correct chat slug
  3. Create a new key for the correct chat interface

"Chat interface not found" Error

Problem: The chat slug doesn't exist or is inactive

Solutions:

  1. Check the slug in your dashboard
  2. Verify the chat interface is active
  3. Make sure you're using the correct URL

No Response / Timeout

Problem: Request takes too long or fails

Solutions:

  1. Check your internet connection
  2. Verify the API endpoint URL is correct
  3. Try again (might be temporary server issue)
  4. Check if knowledge base is processing documents

📖 API Reference

Endpoint

POST https://public.axiestudio.se/api/v1/chat/{slug}

Headers

Authorization: Bearer axie_your_key_here
Content-Type: application/json

Request Body

{
"message": "Your question here",
"sessionId": "optional-session-id"
}

Response

{
"success": true,
"message": "AI response",
"sources": [...],
"usage": {...},
"sessionId": "session-id",
"toolCalls": [...],
"formConfig": {...}
}

🎓 Advanced Topics

Managing Multiple Keys

Best Practice:

Production Website    → Key 1 (never expires)
Mobile App → Key 2 (never expires)
Testing → Key 3 (expires in 30 days)
External Contractor → Key 4 (expires when project ends)

Monitoring Usage

Track your API key usage in the dashboard:

  • Last Used: When was this key last used?
  • Usage Count: How many API calls have been made?
  • Status: Is the key active?

Rotating Keys

For security, rotate keys periodically:

  1. Create new API key
  2. Update your application with new key
  3. Test thoroughly
  4. Deactivate old key
  5. Monitor for any issues
  6. Delete old key after 30 days

💡 Tips & Tricks

Tip 1: Use Descriptive Names

✅ GOOD:
- "Production Website Chat"
- "Mobile App v2.0"
- "Zapier Integration"

❌ BAD:
- "Key 1"
- "Test"
- "New Key"

Tip 2: Test Before Going Live

Always test your API integration:

  1. Create a test API key
  2. Use a test chat interface
  3. Verify responses are correct
  4. Check error handling
  5. Then create production key

Tip 3: Handle Errors Gracefully

try {
const response = await fetch(apiUrl, options);
const data = await response.json();

if (!data.success) {
// Show user-friendly error
console.error('Chat error:', data.error);
showMessage('Sorry, I had trouble processing that. Please try again.');
}
} catch (error) {
// Network error
console.error('Network error:', error);
showMessage('Connection error. Please check your internet.');
}

🆘 Need Help?

Support Resources

Before Contacting Support

Have ready:

  1. Your API key prefix (e.g., axie_abc...)
  2. Chat interface slug
  3. Error messages
  4. Example request/response

🎯 Next Steps

Now that you understand API keys:

  1. Create your first chat interface →
  2. Add a knowledge base →
  3. Explore integrations →
  4. View analytics →

Ready to Start?

Go to Dashboard → API Keys and create your first API key! Start building in minutes. 🚀


Last Updated: 2025-01-27
API Version: v1.0.0
Base URL: https://public.axiestudio.se/api/v1