Never expose your API key in frontend or client-side code. Always call jack from your backend. If a key is compromised, revoke it from the dashboard and generate a new one.
Step 3 — Ingest a document
Send your document text to POST /v1/ingest. Include metadata — it lets you filter queries to specific subsets of your documents later.
python
import httpx
response = httpx.post(
"https://api.usejack.io/v1/ingest",
headers={"Authorization": "Bearer jack_xxxxxxxx"},
json={
"documents": [
{
"text": "Section 4.2 — Remote Work Policy. Employees are permitted to work remotely...",
"metadata": {
"document_type": "policy",
"department": "HR",
"version": "2024-Q1"
}
}
]
}
)
data = response.json()
doc_id = data["document_ids"][0]
print(doc_id) # f6c5ea1b-4d9b-4fbf-bb18-b10b97680340
Ingest is asynchronous. The API returns 202 Accepted immediately. Save your document_ids — you need them to check status and delete documents.
Step 4 — Wait for ready
Poll GET /v1/documents/{document_id} until status is ready. Most documents are ready in under 60 seconds.
python
import time
def wait_until_ready(doc_id: str, api_key: str, timeout: int = 120) -> bool:
start = time.time()
while time.time() - start < timeout:
resp = httpx.get(
f"https://api.usejack.io/v1/documents/{doc_id}",
headers={"Authorization": f"Bearer {api_key}"}
)
status = resp.json().get("status")
if status == "ready":
return True
if status == "failed":
return False
time.sleep(5)
return False
ready = wait_until_ready(doc_id, "jack_xxxxxxxx")
print("Ready:", ready)
Step 5 — Ask your first question
POST a plain-English question to /v1/query. Get back an answer and the exact source it came from.
python
response = httpx.post(
"https://api.usejack.io/v1/query",
headers={"Authorization": "Bearer jack_xxxxxxxx"},
json={
"question": "What is the remote work policy?",
"filters": {"department": "HR"}
},
timeout=30
)
data = response.json()
print(data["answer"])
# "Employees may work remotely up to 3 days per week with manager approval..."
print(data["citations"][0]["source"])
# "remote-work-policy.pdf"
Step 6 — Try streaming
Use /v1/query/stream to stream tokens in real time — ideal for a ChatGPT-style typing effect in your UI.
python
import httpx, json
with httpx.stream(
"POST",
"https://api.usejack.io/v1/query/stream",
headers={"Authorization": "Bearer jack_xxxxxxxx"},
json={"question": "What is the remote work policy?"},
timeout=60
) as resp:
for line in resp.iter_lines():
if line.startswith("data: "):
payload = line[6:]
if payload == "[DONE]":
break
event = json.loads(payload)
if "token" in event:
print(event["token"], end="", flush=True)
Quickstart checklist
Sign up at usejack.io
Generate an API key from the dashboard
Ingest one document — POST /v1/ingest
Poll until status is ready — GET /v1/documents/{id}