# Start a knowledge job

`POST https://ai.inovacc.dev/v1/knowledge/jobs`

Start building a knowledge base from a completed upload of a recording.

## Body params

- `upload_id` (string), required: The id of a completed upload of the recording (its `X-Operation-Id` at `POST /v1/uploads`).
- `max_price_usd` (string), required: The most the job may cost, a decimal greater than zero such as `"5.00"`. Over your organization's cap it is refused before any paid work.
- `spoken_language` (string): The language the recording is in, such as `en` or `pt-BR`: a hint for transcription.
- `output_language` (string): The language the knowledge base is written in. Default English; quotes and the transcript are never translated.
- `power` ("light" | "medium" | "max"): The quality setting. Default `medium`; `light` turns off evidence reconciliation and extraction.
- `max_pointers` (integer): How many still frames the knowledge base may reference, 1 to 50.
- `keep_source_hours` (integer): Keep the recording after the job, so another job can reuse it: 1 to 168 hours, within your organization's cap.
- `references` (object): Supporting material: `transcript` and `notes`, each the id of a completed upload of at most 16 MiB.
- `transcript` (string): The meeting's own transcript; speaker names it carries improve who-said-what attribution.
- `notes` (string): A supporting notes document, in plain text or Markdown.
- `adaptive_evidence_reconciliation` (object): `{"enabled": false}` skips checking each entry against the evidence. Default from `power`.
- `adaptive_evidence_extraction` (object): `{"enabled": false}` captures no frames. Default from `power`.

## Headers

- `Authorization` (string), required: Bearer <API key>
- `X-Operation-Id` (string), required: a unique id you choose, on every call except GET
- `Content-Type` (string), required: application/json, on a call with a body

## Request

**cURL**

```sh
curl -X POST "https://ai.inovacc.dev/v1/knowledge/jobs" \
  -H "Authorization: Bearer $INOVACC_API_KEY" \
  -H "X-Operation-Id: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
  "upload_id": "client_up_00000001",
  "spoken_language": "en",
  "max_price_usd": "5.00",
  "references": {
    "transcript": "client_up_transcript01",
    "notes": "client_up_notes000001"
  }
}'
```

**TypeScript**

```ts
import crypto from "node:crypto";

const body: Record<string, unknown> = {
  "upload_id": "client_up_00000001",
  "spoken_language": "en",
  "max_price_usd": "5.00",
  "references": {
    "transcript": "client_up_transcript01",
    "notes": "client_up_notes000001"
  }
};

const url = "https://ai.inovacc.dev/v1/knowledge/jobs";

const response = await fetch(url, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.INOVACC_API_KEY}`,
    "X-Operation-Id": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify(body),
});

console.log(response.status, await response.text());
```

**Python**

```py
import json
import os
import urllib.request
import uuid

body = {
    "upload_id": "client_up_00000001",
    "spoken_language": "en",
    "max_price_usd": "5.00",
    "references": {
        "transcript": "client_up_transcript01",
        "notes": "client_up_notes000001",
    },
}

request = urllib.request.Request(
    "https://ai.inovacc.dev/v1/knowledge/jobs",
    data=json.dumps(body).encode(),
    method="POST",
    headers={
        "User-Agent": "inovacc-python-sample",
        "Authorization": "Bearer " + os.environ["INOVACC_API_KEY"],
        "X-Operation-Id": str(uuid.uuid4()),
        "Content-Type": "application/json",
    },
)

with urllib.request.urlopen(request) as response:
    print(response.status, response.read().decode())
```

**Go**

```go
package main

import (
	"crypto/rand"
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

const url = "https://ai.inovacc.dev/v1/knowledge/jobs"

const body = `{
  "upload_id": "client_up_00000001",
  "spoken_language": "en",
  "max_price_usd": "5.00",
  "references": {
    "transcript": "client_up_transcript01",
    "notes": "client_up_notes000001"
  }
}`

// newUUID returns a random (version 4) UUID, from the standard library alone.
func newUUID() string {
	b := make([]byte, 16)
	if _, err := rand.Read(b); err != nil {
		panic(err)
	}
	b[6] = b[6]&0x0f | 0x40
	b[8] = b[8]&0x3f | 0x80
	return fmt.Sprintf("%x-%x-%x-%x-%x", b[0:4], b[4:6], b[6:8], b[8:10], b[10:])
}

func main() {
	req, err := http.NewRequest("POST", url, strings.NewReader(body))
	if err != nil {
		panic(err)
	}
	req.Header.Set("Authorization", "Bearer "+os.Getenv("INOVACC_API_KEY"))
	req.Header.Set("X-Operation-Id", newUUID())
	req.Header.Set("Content-Type", "application/json")

	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()

	out, err := io.ReadAll(res.Body)
	if err != nil {
		panic(err)
	}
	fmt.Println(res.Status, string(out))
}
```

**Rust**

```rs
// Cargo.toml: reqwest = { version = "0.12", features = ["blocking", "json"] }
// Cargo.toml: serde_json = "1"
// Cargo.toml: uuid = { version = "1", features = ["v4"] }

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let api_key = std::env::var("INOVACC_API_KEY")?;
    let body = serde_json::json!({
        "upload_id": "client_up_00000001",
        "spoken_language": "en",
        "max_price_usd": "5.00",
        "references": {
            "transcript": "client_up_transcript01",
            "notes": "client_up_notes000001"
        }
    });
    let response = reqwest::blocking::Client::new()
        .post("https://ai.inovacc.dev/v1/knowledge/jobs")
        .bearer_auth(api_key)
        .header("X-Operation-Id", uuid::Uuid::new_v4().to_string())
        .json(&body)
        .send()?;
    println!("{} {}", response.status(), response.text()?);
    Ok(())
}
```

**JavaScript**

```mjs
import crypto from "node:crypto";

const body = {
  "upload_id": "client_up_00000001",
  "spoken_language": "en",
  "max_price_usd": "5.00",
  "references": {
    "transcript": "client_up_transcript01",
    "notes": "client_up_notes000001"
  }
};

const url = "https://ai.inovacc.dev/v1/knowledge/jobs";

const response = await fetch(url, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.INOVACC_API_KEY}`,
    "X-Operation-Id": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify(body),
});

console.log(response.status, await response.text());
```

**PHP**

```php
<?php

$body = <<<'JSON'
{
  "upload_id": "client_up_00000001",
  "spoken_language": "en",
  "max_price_usd": "5.00",
  "references": {
    "transcript": "client_up_transcript01",
    "notes": "client_up_notes000001"
  }
}
JSON;

function uuid4(): string
{
    $bytes = random_bytes(16);
    $bytes[6] = chr(ord($bytes[6]) & 0x0f | 0x40);
    $bytes[8] = chr(ord($bytes[8]) & 0x3f | 0x80);
    return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($bytes), 4));
}

$curl = curl_init('https://ai.inovacc.dev/v1/knowledge/jobs');
curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('INOVACC_API_KEY'),
        'X-Operation-Id: ' . uuid4(),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => $body,
]);

$response = curl_exec($curl);
echo curl_getinfo($curl, CURLINFO_HTTP_CODE), ' ', $response, "\n";
curl_close($curl);
```

**Ruby**

```rb
require "net/http"
require "securerandom"
require "uri"

uri = URI('https://ai.inovacc.dev/v1/knowledge/jobs')
body = <<~'JSON'
{
  "upload_id": "client_up_00000001",
  "spoken_language": "en",
  "max_price_usd": "5.00",
  "references": {
    "transcript": "client_up_transcript01",
    "notes": "client_up_notes000001"
  }
}
JSON

request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV.fetch('INOVACC_API_KEY')}"
request["X-Operation-Id"] = SecureRandom.uuid
request["Content-Type"] = "application/json"
request.body = body

response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http|
  http.request(request)
end

puts "#{response.code} #{response.body}"
```

**Java**

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.UUID;

public class Main {
    public static void main(String[] args) throws Exception {
        String apiKey = System.getenv("INOVACC_API_KEY");
        String body = "{" +
                "\"upload_id\": \"client_up_00000001\"," +
                "\"spoken_language\": \"en\"," +
                "\"max_price_usd\": \"5.00\"," +
                "\"references\": {" +
                "\"transcript\": \"client_up_transcript01\"," +
                "\"notes\": \"client_up_notes000001\"" +
                "}" +
                "}";

        HttpRequest request = HttpRequest.newBuilder()
                .uri(URI.create("https://ai.inovacc.dev/v1/knowledge/jobs"))
                .header("Authorization", "Bearer " + apiKey)
                .header("X-Operation-Id", UUID.randomUUID().toString())
                .header("Content-Type", "application/json")
                .method("POST", HttpRequest.BodyPublishers.ofString(body))
                .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
                .send(request, HttpResponse.BodyHandlers.ofString());
        System.out.println(response.statusCode() + " " + response.body());
    }
}
```

**C#**

```cs
using System.Text;

var body = "{" +
    "\"upload_id\": \"client_up_00000001\"," +
    "\"spoken_language\": \"en\"," +
    "\"max_price_usd\": \"5.00\"," +
    "\"references\": {" +
    "\"transcript\": \"client_up_transcript01\"," +
    "\"notes\": \"client_up_notes000001\"" +
    "}" +
    "}";

var url = "https://ai.inovacc.dev/v1/knowledge/jobs";
var apiKey = Environment.GetEnvironmentVariable("INOVACC_API_KEY");

using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, url);
request.Headers.Add("Authorization", $"Bearer {apiKey}");
request.Headers.Add("X-Operation-Id", Guid.NewGuid().ToString());
request.Content = new StringContent(body, Encoding.UTF8, "application/json");

using var response = await client.SendAsync(request);
Console.WriteLine($"{(int)response.StatusCode} {await response.Content.ReadAsStringAsync()}");
```

**Kotlin**

```kt
import java.net.URI
import java.net.http.HttpClient
import java.net.http.HttpRequest
import java.net.http.HttpResponse
import java.util.UUID

fun main() {
    val apiKey = System.getenv("INOVACC_API_KEY")
    val body = "{" +
        "\"upload_id\": \"client_up_00000001\"," +
        "\"spoken_language\": \"en\"," +
        "\"max_price_usd\": \"5.00\"," +
        "\"references\": {" +
        "\"transcript\": \"client_up_transcript01\"," +
        "\"notes\": \"client_up_notes000001\"" +
        "}" +
        "}"

    val request = HttpRequest.newBuilder()
        .uri(URI.create("https://ai.inovacc.dev/v1/knowledge/jobs"))
        .header("Authorization", "Bearer " + apiKey)
        .header("X-Operation-Id", UUID.randomUUID().toString())
        .header("Content-Type", "application/json")
        .method("POST", HttpRequest.BodyPublishers.ofString(body))
        .build()

    val response = HttpClient.newHttpClient()
        .send(request, HttpResponse.BodyHandlers.ofString())
    println("${response.statusCode()} ${response.body()}")
}
```

**Swift**

```swift
import Foundation
#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

let body = #"""
{
  "upload_id": "client_up_00000001",
  "spoken_language": "en",
  "max_price_usd": "5.00",
  "references": {
    "transcript": "client_up_transcript01",
    "notes": "client_up_notes000001"
  }
}
"""#

let apiKey = ProcessInfo.processInfo.environment["INOVACC_API_KEY"] ?? ""

let url = URL(string: "https://ai.inovacc.dev/v1/knowledge/jobs")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
request.setValue(UUID().uuidString, forHTTPHeaderField: "X-Operation-Id")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = Data(body.utf8)

let (data, response) = try await URLSession.shared.data(for: request)
let status = (response as? HTTPURLResponse)?.statusCode ?? 0
print(status, String(decoding: data, as: UTF8.self))
```

## Response

**202**

```json
{
  "job_id": "client_op_job_00001",
  "poll_after_seconds": 142,
  "status_url": "/v1/knowledge/jobs/client_op_job_00001"
}
```

**400**: missing_operation_id, invalid_operation_id, invalid_body

**403**: knowledge_disabled, budget_exceeded

**404**: upload_not_found

**409**: operation_in_progress, upload_incomplete

**413**: request_too_large

**502**: upstream_error

**503**: service_unavailable

## See also

- [Authentication](https://developer.inovacc.dev/en/guides/authentication/)
- [Errors](https://developer.inovacc.dev/en/guides/errors/)
- [Limits](https://developer.inovacc.dev/en/guides/limits/)
