Skip to main content
This guide will walk you through the basics of using the Soar Labs API to create a corpus, add a resource to it, and perform a query.

Get an API Token

Before you can use the Soar Labs API, generate a personal access token from the Soar Labs web application’s user settings. Include it in every request via the Authorization header.
Authorization: Bearer YOUR_API_TOKEN

Create a Corpus

Every resource must live inside a corpus. Create one with the corpora endpoint and keep the returned id handy for later steps.
curl -X POST https://your-soar-instance.com/api/corpora/ \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "corpora_name": "My First Corpus", "description": "A corpus for testing the Soar Labs API." }'

Add a Resource

Ingest content so it can be indexed. This example adds a simple string resource, but you can also upload files or URLs.
curl -X POST https://your-soar-instance.com/api/data/strings/ \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "corpora": "your-corpus-id", "title": "Test String", "string": "The quick brown fox jumps over the lazy dog." }'

Run a Query

Once indexing completes, send a query to retrieve answers and citations from your corpus.
curl -X POST https://your-soar-instance.com/api/query/ \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{ "corpora": "your-corpus-id", "user_query": "What does the fox do?", "is_query": true }'

Next Steps

Now that you’ve got the basics down, you can explore the rest of the API to manage your corpora and resources, and to perform more complex queries. Check out the API Reference for more details.