Home / AI Writer and product descriptions through the API

AI Writer and product descriptions through the API

AI Writer and product descriptions through the API. HTTP requests, parameters, response schemas and Labrika workflows.

On this page

AI Writer

The API lets you check the AI Writer balance, calculate the optimization cost, start the optimization, and retrieve the completed document. Operations use separate scopes: ai-writer:read, ai-optimization:read and ai-optimization:write.

Optimization runs asynchronously. Save the document_id from the start response and request the document until its status becomes success or error. When the status is pending, use retry_after_seconds.
GET /public-api/v1/ai-writer/balance

Returns the current credit balance. Requires the ai-writer:read scope.

Example request
curl
curl --fail-with-body --silent --show-error --location \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Accept: application/json' \
  'https://app.labrika.com/public-api/v1/ai-writer/balance'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api/v1/ai-writer/balance", {
    method: "GET",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
    },
    signal: AbortSignal.timeout(30_000),
  })

  if (!response.ok) {
    const responseText = await response.text()
    throw new Error(`HTTP ${response.status}: ${responseText}`)
  }

  const responseText = await response.text()
  const data = responseText && response.headers.get("content-type")?.includes("application/json") ? JSON.parse(responseText) : responseText

  console.log(data)
}

main().catch(error => {
  console.error(error)
  process.exitCode = 1
})
Python
import json
import requests

url = "https://app.labrika.com/public-api/v1/ai-writer/balance"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Accept": "application/json",
}

response = requests.request(
    "GET",
    url,
    headers=headers,
    timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2) if response.content and "application/json" in response.headers.get("Content-Type", "") else response.text)
PHP
<?php

$curl = curl_init('https://app.labrika.com/public-api/v1/ai-writer/balance');

if ($curl === false) {
    throw new RuntimeException('Unable to initialize cURL');
}

curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_API_KEY',
        'Accept: application/json',
    ],
]);

$response = curl_exec($curl);

if ($response === false) {
    $message = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException('Network error: ' . $message);
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("HTTP $status: $response");
}

if ($response !== '' && str_contains($contentType, 'application/json')) {
    print_r(json_decode($response, true, 512, JSON_THROW_ON_ERROR));
} else {
    echo $response;
}
Go
package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"os"
	"time"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
	defer cancel()

	request, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://app.labrika.com/public-api/v1/ai-writer/balance", nil)
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	request.Header.Set("Accept", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
		errorBody, readErr := io.ReadAll(response.Body)
		if readErr != nil {
			panic(readErr)
		}
		panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
	}

	if _, err := io.Copy(os.Stdout, response.Body); err != nil {
		panic(err)
	}
}
Google Apps Script
function callLabrikaPublicAPI() {
  const response = UrlFetchApp.fetch("https://app.labrika.com/public-api/v1/ai-writer/balance", {
    method: "get",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
    },
    followRedirects: false,
    muteHttpExceptions: true,
  });
  const status = response.getResponseCode();
  if (status < 200 || status >= 300) {
    throw new Error('HTTP ' + status + ': ' + response.getContentText());
  }
  Logger.log(response.getContentText());
}
Response · 200 OK
{
  "total_credits": 10000
}
Field Type Description
total_credits integer Current AI Writer balance.
POST /public-api/v1/ai-writer/optimization/cost

Calculates the cost without starting an optimization. Requires the ai-optimization:read scope. The JSON body must not exceed 3 MiB.

With adjust_text_length=false, the price is calculated immediately from the submitted text. With true, the first request returns 202 with estimate_id, expires_at and retry_after_seconds: recommendations are being prepared without charging credits. Repeat the same cost request until 200. Then send the same body to /documents, adding the returned estimate_id: the displayed price based on the recommended length will be charged. The estimate is valid for one hour from preparation and one launch; changed input or reuse returns 409.

JSON body
Field Type Description and constraints
keywords string[] Keywords used to analyze search results and optimize the text. Required; from 1 to 10 keywords.
search_engine string Search engine whose results are used for analysis: google.
region_code string Search results region used for competitor analysis. Specify the required numeric ID: for Google, use the Criteria ID from the geotargeting reference.
language string Language of the text being optimized. For example, use en for English. See SiteLanguage for the accepted codes.
title string Optional. Content of the HTML title tag to optimize. Up to 256 characters.
description string Optional. Content of the description meta tag to optimize. Up to 500 characters.
h1 string Optional. Text of the h1 heading to optimize. Up to 256 characters.
content string HTML page content to analyze and optimize. Up to 512,000 Unicode characters.
adjust_text_length boolean Whether to adjust the text length to the recommended word-count range. The default is true.
Example request
curl
curl --fail-with-body --silent --show-error --location \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "keywords": [
    "seo audit"
  ],
  "search_engine": "google",
  "region_code": "2840",
  "language": "en",
  "title": "SEO Audit",
  "description": "SEO audit service",
  "h1": "SEO Audit",
  "content": "<p>Run a complete SEO audit of your website.</p>",
  "adjust_text_length": true
}' \
  'https://app.labrika.com/public-api/v1/ai-writer/optimization/cost'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api/v1/ai-writer/optimization/cost", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      "keywords": [
        "seo audit"
      ],
      "search_engine": "google",
      "region_code": "2840",
      "language": "en",
      "title": "SEO Audit",
      "description": "SEO audit service",
      "h1": "SEO Audit",
      "content": "<p>Run a complete SEO audit of your website.</p>",
      "adjust_text_length": true
    }),
    signal: AbortSignal.timeout(30_000),
  })

  if (!response.ok) {
    const responseText = await response.text()
    throw new Error(`HTTP ${response.status}: ${responseText}`)
  }

  const responseText = await response.text()
  const data = responseText && response.headers.get("content-type")?.includes("application/json") ? JSON.parse(responseText) : responseText

  console.log(data)
}

main().catch(error => {
  console.error(error)
  process.exitCode = 1
})
Python
import json
import requests

url = "https://app.labrika.com/public-api/v1/ai-writer/optimization/cost"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Accept": "application/json",
    "Content-Type": "application/json",
}
payload = json.loads("{\n  \"keywords\": [\n    \"seo audit\"\n  ],\n  \"search_engine\": \"google\",\n  \"region_code\": \"2840\",\n  \"language\": \"en\",\n  \"title\": \"SEO Audit\",\n  \"description\": \"SEO audit service\",\n  \"h1\": \"SEO Audit\",\n  \"content\": \"<p>Run a complete SEO audit of your website.</p>\",\n  \"adjust_text_length\": true\n}")

response = requests.request(
    "POST",
    url,
    headers=headers,
    json=payload,
    timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2) if response.content and "application/json" in response.headers.get("Content-Type", "") else response.text)
PHP
<?php

$curl = curl_init('https://app.labrika.com/public-api/v1/ai-writer/optimization/cost');

if ($curl === false) {
    throw new RuntimeException('Unable to initialize cURL');
}

curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_API_KEY',
        'Accept: application/json',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => '{
  "keywords": [
    "seo audit"
  ],
  "search_engine": "google",
  "region_code": "2840",
  "language": "en",
  "title": "SEO Audit",
  "description": "SEO audit service",
  "h1": "SEO Audit",
  "content": "<p>Run a complete SEO audit of your website.</p>",
  "adjust_text_length": true
}',
]);

$response = curl_exec($curl);

if ($response === false) {
    $message = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException('Network error: ' . $message);
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("HTTP $status: $response");
}

if ($response !== '' && str_contains($contentType, 'application/json')) {
    print_r(json_decode($response, true, 512, JSON_THROW_ON_ERROR));
} else {
    echo $response;
}
Go
package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
	"time"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
	defer cancel()

	request, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://app.labrika.com/public-api/v1/ai-writer/optimization/cost", strings.NewReader("{\n  \"keywords\": [\n    \"seo audit\"\n  ],\n  \"search_engine\": \"google\",\n  \"region_code\": \"2840\",\n  \"language\": \"en\",\n  \"title\": \"SEO Audit\",\n  \"description\": \"SEO audit service\",\n  \"h1\": \"SEO Audit\",\n  \"content\": \"<p>Run a complete SEO audit of your website.</p>\",\n  \"adjust_text_length\": true\n}"))
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	request.Header.Set("Accept", "application/json")
	request.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
		errorBody, readErr := io.ReadAll(response.Body)
		if readErr != nil {
			panic(readErr)
		}
		panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
	}

	if _, err := io.Copy(os.Stdout, response.Body); err != nil {
		panic(err)
	}
}
Google Apps Script
function callLabrikaPublicAPI() {
  const response = UrlFetchApp.fetch("https://app.labrika.com/public-api/v1/ai-writer/optimization/cost", {
    method: "post",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
    },
    payload: "{\n  \"keywords\": [\n    \"seo audit\"\n  ],\n  \"search_engine\": \"google\",\n  \"region_code\": \"2840\",\n  \"language\": \"en\",\n  \"title\": \"SEO Audit\",\n  \"description\": \"SEO audit service\",\n  \"h1\": \"SEO Audit\",\n  \"content\": \"<p>Run a complete SEO audit of your website.</p>\",\n  \"adjust_text_length\": true\n}",
    followRedirects: false,
    muteHttpExceptions: true,
  });
  const status = response.getResponseCode();
  if (status < 200 || status >= 300) {
    throw new Error('HTTP ' + status + ': ' + response.getContentText());
  }
  Logger.log(response.getContentText());
}
Response · 200 OK
{
  "estimate_id": "d3k9gp386g2uo3ei6sg0",
  "expires_at": "2026-11-17T12:00:00Z",
  "cost": 120,
  "total_credits": 10000,
  "remaining_credits": 9880,
  "has_enough_credits": true
}
Field Type Description
cost integer Number of credits required to start the optimization.
total_credits integer Current AI Writer balance.
remaining_credits integer Estimated credit balance after starting the optimization.
has_enough_credits boolean Whether the current balance is sufficient to start the optimization.
If the request body exceeds this limit, the API returns 413.
POST /public-api/v1/ai-writer/optimization/documents

Starts an optimization with the same JSON body used for cost calculation. Requires the ai-optimization:write scope. An optional Idempotency-Key header allows the request to be retried safely without starting the optimization again or charging credits again. The key must contain 1–128 characters from A-Z a-z 0-9 . _ : -.

Example request
curl
curl --fail-with-body --silent --show-error --location \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: optimization-001' \
  --data '{
  "keywords": [
    "seo audit"
  ],
  "search_engine": "google",
  "region_code": "2840",
  "language": "en",
  "title": "SEO Audit",
  "description": "SEO audit service",
  "h1": "SEO Audit",
  "content": "<p>Run a complete SEO audit of your website.</p>",
  "adjust_text_length": true,
  "estimate_id": "d3k9gp386g2uo3ei6sg0"
}' \
  'https://app.labrika.com/public-api/v1/ai-writer/optimization/documents'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api/v1/ai-writer/optimization/documents", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
      "Idempotency-Key": "optimization-001",
    },
    body: JSON.stringify({
      "keywords": [
        "seo audit"
      ],
      "search_engine": "google",
      "region_code": "2840",
      "language": "en",
      "title": "SEO Audit",
      "description": "SEO audit service",
      "h1": "SEO Audit",
      "content": "<p>Run a complete SEO audit of your website.</p>",
      "adjust_text_length": true,
      "estimate_id": "d3k9gp386g2uo3ei6sg0"
    }),
    signal: AbortSignal.timeout(30_000),
  })

  if (!response.ok) {
    const responseText = await response.text()
    throw new Error(`HTTP ${response.status}: ${responseText}`)
  }

  const responseText = await response.text()
  const data = responseText && response.headers.get("content-type")?.includes("application/json") ? JSON.parse(responseText) : responseText

  console.log(data)
}

main().catch(error => {
  console.error(error)
  process.exitCode = 1
})
Python
import json
import requests

url = "https://app.labrika.com/public-api/v1/ai-writer/optimization/documents"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Idempotency-Key": "optimization-001",
}
payload = json.loads("{\n  \"keywords\": [\n    \"seo audit\"\n  ],\n  \"search_engine\": \"google\",\n  \"region_code\": \"2840\",\n  \"language\": \"en\",\n  \"title\": \"SEO Audit\",\n  \"description\": \"SEO audit service\",\n  \"h1\": \"SEO Audit\",\n  \"content\": \"<p>Run a complete SEO audit of your website.</p>\",\n  \"adjust_text_length\": true,\n  \"estimate_id\": \"d3k9gp386g2uo3ei6sg0\"\n}")

response = requests.request(
    "POST",
    url,
    headers=headers,
    json=payload,
    timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2) if response.content and "application/json" in response.headers.get("Content-Type", "") else response.text)
PHP
<?php

$curl = curl_init('https://app.labrika.com/public-api/v1/ai-writer/optimization/documents');

if ($curl === false) {
    throw new RuntimeException('Unable to initialize cURL');
}

curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_API_KEY',
        'Accept: application/json',
        'Content-Type: application/json',
        'Idempotency-Key: optimization-001',
    ],
    CURLOPT_POSTFIELDS => '{
  "keywords": [
    "seo audit"
  ],
  "search_engine": "google",
  "region_code": "2840",
  "language": "en",
  "title": "SEO Audit",
  "description": "SEO audit service",
  "h1": "SEO Audit",
  "content": "<p>Run a complete SEO audit of your website.</p>",
  "adjust_text_length": true,
  "estimate_id": "d3k9gp386g2uo3ei6sg0"
}',
]);

$response = curl_exec($curl);

if ($response === false) {
    $message = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException('Network error: ' . $message);
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("HTTP $status: $response");
}

if ($response !== '' && str_contains($contentType, 'application/json')) {
    print_r(json_decode($response, true, 512, JSON_THROW_ON_ERROR));
} else {
    echo $response;
}
Go
package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
	"time"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
	defer cancel()

	request, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://app.labrika.com/public-api/v1/ai-writer/optimization/documents", strings.NewReader("{\n  \"keywords\": [\n    \"seo audit\"\n  ],\n  \"search_engine\": \"google\",\n  \"region_code\": \"2840\",\n  \"language\": \"en\",\n  \"title\": \"SEO Audit\",\n  \"description\": \"SEO audit service\",\n  \"h1\": \"SEO Audit\",\n  \"content\": \"<p>Run a complete SEO audit of your website.</p>\",\n  \"adjust_text_length\": true,\n  \"estimate_id\": \"d3k9gp386g2uo3ei6sg0\"\n}"))
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	request.Header.Set("Accept", "application/json")
	request.Header.Set("Content-Type", "application/json")
	request.Header.Set("Idempotency-Key", "optimization-001")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
		errorBody, readErr := io.ReadAll(response.Body)
		if readErr != nil {
			panic(readErr)
		}
		panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
	}

	if _, err := io.Copy(os.Stdout, response.Body); err != nil {
		panic(err)
	}
}
Google Apps Script
function callLabrikaPublicAPI() {
  const response = UrlFetchApp.fetch("https://app.labrika.com/public-api/v1/ai-writer/optimization/documents", {
    method: "post",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
      "Idempotency-Key": "optimization-001",
    },
    payload: "{\n  \"keywords\": [\n    \"seo audit\"\n  ],\n  \"search_engine\": \"google\",\n  \"region_code\": \"2840\",\n  \"language\": \"en\",\n  \"title\": \"SEO Audit\",\n  \"description\": \"SEO audit service\",\n  \"h1\": \"SEO Audit\",\n  \"content\": \"<p>Run a complete SEO audit of your website.</p>\",\n  \"adjust_text_length\": true,\n  \"estimate_id\": \"d3k9gp386g2uo3ei6sg0\"\n}",
    followRedirects: false,
    muteHttpExceptions: true,
  });
  const status = response.getResponseCode();
  if (status < 200 || status >= 300) {
    throw new Error('HTTP ' + status + ': ' + response.getContentText());
  }
  Logger.log(response.getContentText());
}
Response · 202 Accepted
{
  "cost": 120,
  "total_credits": 10000,
  "remaining_credits": 9880,
  "has_enough_credits": true,
  "document_id": "01k3m8v7g6c5v4b3n2a1",
  "status": "pending"
}
Field Type Description
cost integer Number of credits charged for the optimization.
total_credits integer Credit balance before the optimization cost was charged.
remaining_credits integer Credit balance after the optimization cost was charged.
has_enough_credits boolean Whether there were enough credits to start the optimization.
document_id string Optimization ID. Use it to check the status and retrieve the completed document.
status string The initial status is pending: the optimization has been accepted and is running.
  • 422 — insufficient credits; the response contains the cost calculation.
  • 409 — conflicting reuse of Idempotency-Key.
  • 413 — the JSON body is larger than 3 MiB.
GET /public-api/v1/ai-writer/optimization/documents/{document_id}

Returns the optimization status or result. Requires the ai-optimization:read scope. Pass the identifier in document_id from the optimization start response: 20 characters in the range 0-9a-v.

Example request
curl
curl --fail-with-body --silent --show-error --location \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Accept: application/json' \
  'https://app.labrika.com/public-api/v1/ai-writer/optimization/documents/01k3m8v7g6c5v4b3n2a1'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api/v1/ai-writer/optimization/documents/01k3m8v7g6c5v4b3n2a1", {
    method: "GET",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
    },
    signal: AbortSignal.timeout(30_000),
  })

  if (!response.ok) {
    const responseText = await response.text()
    throw new Error(`HTTP ${response.status}: ${responseText}`)
  }

  const responseText = await response.text()
  const data = responseText && response.headers.get("content-type")?.includes("application/json") ? JSON.parse(responseText) : responseText

  console.log(data)
}

main().catch(error => {
  console.error(error)
  process.exitCode = 1
})
Python
import json
import requests

url = "https://app.labrika.com/public-api/v1/ai-writer/optimization/documents/01k3m8v7g6c5v4b3n2a1"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Accept": "application/json",
}

response = requests.request(
    "GET",
    url,
    headers=headers,
    timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2) if response.content and "application/json" in response.headers.get("Content-Type", "") else response.text)
PHP
<?php

$curl = curl_init('https://app.labrika.com/public-api/v1/ai-writer/optimization/documents/01k3m8v7g6c5v4b3n2a1');

if ($curl === false) {
    throw new RuntimeException('Unable to initialize cURL');
}

curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_API_KEY',
        'Accept: application/json',
    ],
]);

$response = curl_exec($curl);

if ($response === false) {
    $message = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException('Network error: ' . $message);
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("HTTP $status: $response");
}

if ($response !== '' && str_contains($contentType, 'application/json')) {
    print_r(json_decode($response, true, 512, JSON_THROW_ON_ERROR));
} else {
    echo $response;
}
Go
package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"os"
	"time"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
	defer cancel()

	request, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://app.labrika.com/public-api/v1/ai-writer/optimization/documents/01k3m8v7g6c5v4b3n2a1", nil)
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	request.Header.Set("Accept", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
		errorBody, readErr := io.ReadAll(response.Body)
		if readErr != nil {
			panic(readErr)
		}
		panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
	}

	if _, err := io.Copy(os.Stdout, response.Body); err != nil {
		panic(err)
	}
}
Google Apps Script
function callLabrikaPublicAPI() {
  const response = UrlFetchApp.fetch("https://app.labrika.com/public-api/v1/ai-writer/optimization/documents/01k3m8v7g6c5v4b3n2a1", {
    method: "get",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
    },
    followRedirects: false,
    muteHttpExceptions: true,
  });
  const status = response.getResponseCode();
  if (status < 200 || status >= 300) {
    throw new Error('HTTP ' + status + ': ' + response.getContentText());
  }
  Logger.log(response.getContentText());
}
Response fields
Field Type Description
document_id string Identifier of the requested optimization.
status string Optimization status: pending — running, success — completed, error — failed.
retry_after_seconds integer Recommended delay in seconds before the next status request. Returned when the status is pending.
progress_percent integer Current optimization progress from 0 to 100 percent. May be returned when the status is pending.
title string Optimized content of the HTML title tag.
description string Optimized content of the description meta tag.
h1 string Optimized text of the h1 heading.
content string Optimized HTML page content.
credits_spent integer Actual number of AI Writer credits charged after a successful optimization. Returned only when status=success.
seo_score number SEO score from 0 to 100, rounded to two decimal places.
recommended_words_min integer Lower bound of the recommended word count.
recommended_words_max integer Upper bound of the recommended word count.
actual_words integer Actual word count in the optimized text.
error_code string Machine-readable optimization error code. Returned when status=error.
In progress · 200 OK
{
  "document_id": "01k3m8v7g6c5v4b3n2a1",
  "status": "pending",
  "retry_after_seconds": 10,
  "progress_percent": 50
}
Completed · 200 OK
{
  "document_id": "01k3m8v7g6c5v4b3n2a1",
  "status": "success",
  "credits_spent": 120,
  "title": "SEO Audit",
  "description": "SEO audit service",
  "h1": "SEO Audit",
  "content": "<p>Optimized content.</p>",
  "seo_score": 100,
  "recommended_words_min": 100,
  "recommended_words_max": 140,
  "actual_words": 120
}
If the document does not belong to the current user or does not exist, the API returns 404. When status=error, the response contains error_code.

Before using AI output, check the facts, company or product name, language and consistency with your inputs. Read generated HTML before publication. Technical success does not replace a content review.

Back to contents

API method reference — AIWriter

Choose a method from the contents. Check its HTTP method, path, scopes, required parameters and request body. JSON blocks containing schema, properties and $ref describe the contract; do not send them as a ready-made request body. Request examples and response schemas are labelled separately.

Methods in this section

GET /public-api/v1/ai-writer/balance

Requires the `ai-writer:read` scope.

Related data models: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · AIWriterBalance · ErrorResponse

Responses

200

Current AI Writer credit balance.

{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AIWriterBalance"
      }
    }
  }
}
default

Public API error. Rate-limit headers describe the limit actually checked: failed authentication attempts per IP for missing or invalid keys, or the applicable key/account limit after authentication. They may be absent for access blocks before rate-limit checks or when the limiter is unavailable. X-RateLimit-Reset is a Unix timestamp in seconds; Retry-After is a delay in seconds for 429.

{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

POST /public-api/v1/ai-writer/optimization/cost

Requires the `ai-optimization:read` scope.

Related data models: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · AIWriterOptimizationCost · AIWriterOptimizationEstimate · AIWriterOptimizationEstimatePending · AIWriterOptimizationRequest · ErrorResponse

Request

The JSON request body must not exceed 3 MiB (3145728 bytes).

{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AIWriterOptimizationRequest"
      }
    }
  }
}

Responses

200

Informational cost and current balance.

{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "anyOf": [
          {
            "$ref": "#/components/schemas/AIWriterOptimizationCost"
          },
          {
            "$ref": "#/components/schemas/AIWriterOptimizationEstimate"
          }
        ]
      }
    }
  }
}
202

Recommendations are being prepared without charging credits. Repeat the same cost request.

{
  "headers": {
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AIWriterOptimizationEstimatePending"
      }
    }
  }
}
413
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

POST /public-api/v1/ai-writer/optimization/documents

Requires the `ai-optimization:write` scope.

Related data models: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · AIWriterOptimizationCost · AIWriterOptimizationRequest · AIWriterOptimizationStart · ErrorResponse

Parameters

Idempotency-Key (header)

Optional key used to replay the same completed request for 24 hours.

{
  "schema": {
    "type": "string",
    "minLength": 1,
    "maxLength": 128,
    "pattern": "^[A-Za-z0-9._:-]+$"
  }
}

Request

The JSON request body must not exceed 3 MiB (3145728 bytes).

{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AIWriterOptimizationRequest"
      }
    }
  }
}

Responses

202

Optimization accepted.

{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AIWriterOptimizationStart"
      }
    }
  }
}
422

Insufficient AI Writer credits.

{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AIWriterOptimizationCost"
      }
    }
  }
}
413
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
409
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

GET /public-api/v1/ai-writer/optimization/documents/{document_id}

Requires the `ai-optimization:read` scope.

Related data models: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · AIWriterOptimizationDocument · ErrorResponse

Parameters

document_id (path)
{
  "required": true,
  "schema": {
    "type": "string",
    "pattern": "^[0-9a-v]{20}$"
  }
}
content_view (query)
{
  "schema": {
    "type": "string",
    "enum": [
      "both",
      "plain",
      "annotated"
    ],
    "default": "both"
  }
}

Responses

200

Current optimization state or result.

{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/AIWriterOptimizationDocument"
      }
    }
  }
}
400
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
404
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

POST /public-api/v1/ai-writer/expert-articles/cost

Estimate the maximum AI credits for an expert article. The estimate is valid for 10 minutes.

Related data models: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · ErrorResponse · ExpertArticleEstimate · ExpertArticleInput

Permissions: ai-expert-articles:read

Request

{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ExpertArticleInput"
      }
    }
  }
}

Responses

200

Estimate the maximum AI credits for an expert article. The estimate is valid for 10 minutes.

{
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ExpertArticleEstimate"
          }
        }
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

POST /public-api/v1/ai-writer/expert-articles/documents

Start writing an expert article using the estimate and its Idempotency-Key. Repeat the same request to retrieve the original launch result.

Related data models: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · ErrorResponse · ExpertArticleStart · ExpertArticleStartInput

Permissions: ai-expert-articles:write

Parameters

Idempotency-Key (header)
{
  "required": true,
  "schema": {
    "type": "string",
    "minLength": 1,
    "maxLength": 128,
    "pattern": "^[A-Za-z0-9._:-]+$"
  }
}

Request

{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ExpertArticleStartInput"
      }
    }
  }
}

Responses

202

Start writing an expert article using the estimate and its Idempotency-Key. Repeat the same request to retrieve the original launch result.

{
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ExpertArticleStart"
          }
        }
      }
    }
  }
}
409
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
422
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

GET /public-api/v1/ai-writer/expert-articles/documents/{document_id}

Get expert article progress and the generated HTML when generation completes.

Related data models: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · ErrorResponse · ExpertArticleResult

Permissions: ai-expert-articles:read

Parameters

document_id (path)
{
  "required": true,
  "schema": {
    "type": "string",
    "pattern": "^[0-9a-v]{20}$"
  }
}

Responses

200

Get expert article progress and the generated HTML when generation completes.

{
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "required": [
          "data"
        ],
        "properties": {
          "data": {
            "$ref": "#/components/schemas/ExpertArticleResult"
          }
        }
      }
    }
  }
}
404
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

Before using AI output, check the facts, company or product name, language and consistency with your inputs. Read generated HTML before publication. Technical success does not replace a content review.

Back to contents

Product descriptions

Generate catalog product descriptions from a product name and its features. The API returns HTML content, a page title, a meta description, and H1. Generation runs in the background: estimate the cost, create a document, then retrieve the result by its identifier.

All three fields are required in the JSON body of both POST requests. Send Content-Type: application/json. The body limit is 16 KiB. Creation requires ai-product-descriptions:write; estimation and reading the result require ai-product-descriptions:read.

Parameter Description
title · string Product name and key features: 1–256 characters. Include the model, material, size, or intended use to help identify the product.
language · string A language code from the reference below. This field determines the output language.
word_count · integer Parameter values and target lengths: 400 → 400–600 words; 600 → 600–800 words; 800 → 800–1200 words. The actual word count is returned in actual_words.

Supported languages

Use en to generate an English description. The accepted language codes are listed in ProductDescriptionRequest.

POST /public-api/v1/ai-writer/product-descriptions/cost

Estimates the cost without starting generation or spending credits. The response contains cost, total_credits, remaining_credits, and has_enough_credits. Check has_enough_credits before creating the document; an estimate does not reserve the balance.

curl
curl --fail-with-body --silent --show-error --location \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "title": "Ceramic coffee mug, 350 ml, dishwasher safe",
  "language": "en",
  "word_count": 400
}' \
  'https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/cost'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/cost", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      "title": "Ceramic coffee mug, 350 ml, dishwasher safe",
      "language": "en",
      "word_count": 400
    }),
    signal: AbortSignal.timeout(30_000),
  })

  if (!response.ok) {
    const responseText = await response.text()
    throw new Error(`HTTP ${response.status}: ${responseText}`)
  }

  const responseText = await response.text()
  const data = responseText && response.headers.get("content-type")?.includes("application/json") ? JSON.parse(responseText) : responseText

  console.log(data)
}

main().catch(error => {
  console.error(error)
  process.exitCode = 1
})
Python
import json
import requests

url = "https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/cost"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Accept": "application/json",
    "Content-Type": "application/json",
}
payload = json.loads("{\n  \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}")

response = requests.request(
    "POST",
    url,
    headers=headers,
    json=payload,
    timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2) if response.content and "application/json" in response.headers.get("Content-Type", "") else response.text)
PHP
<?php

$curl = curl_init('https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/cost');

if ($curl === false) {
    throw new RuntimeException('Unable to initialize cURL');
}

curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_API_KEY',
        'Accept: application/json',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => '{
  "title": "Ceramic coffee mug, 350 ml, dishwasher safe",
  "language": "en",
  "word_count": 400
}',
]);

$response = curl_exec($curl);

if ($response === false) {
    $message = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException('Network error: ' . $message);
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("HTTP $status: $response");
}

if ($response !== '' && str_contains($contentType, 'application/json')) {
    print_r(json_decode($response, true, 512, JSON_THROW_ON_ERROR));
} else {
    echo $response;
}
Go
package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
	"time"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
	defer cancel()

	request, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/cost", strings.NewReader("{\n  \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}"))
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	request.Header.Set("Accept", "application/json")
	request.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
		errorBody, readErr := io.ReadAll(response.Body)
		if readErr != nil {
			panic(readErr)
		}
		panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
	}

	if _, err := io.Copy(os.Stdout, response.Body); err != nil {
		panic(err)
	}
}
Google Apps Script
function callLabrikaPublicAPI() {
  const response = UrlFetchApp.fetch("https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/cost", {
    method: "post",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
    },
    payload: "{\n  \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}",
    followRedirects: false,
    muteHttpExceptions: true,
  });
  const status = response.getResponseCode();
  if (status < 200 || status >= 300) {
    throw new Error('HTTP ' + status + ': ' + response.getContentText());
  }
  Logger.log(response.getContentText());
}
POST /public-api/v1/ai-writer/product-descriptions/documents

Starts generation. Send a unique Idempotency-Key for each new document. HTTP 202 returns document_id, status, cost, and has_enough_credits. Save document_id to retrieve the result.

curl
curl --fail-with-body --silent --show-error --location \
  --request POST \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: product-123-description-v1' \
  --data '{
  "title": "Ceramic coffee mug, 350 ml, dishwasher safe",
  "language": "en",
  "word_count": 400
}' \
  'https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
      "Idempotency-Key": "product-123-description-v1",
    },
    body: JSON.stringify({
      "title": "Ceramic coffee mug, 350 ml, dishwasher safe",
      "language": "en",
      "word_count": 400
    }),
    signal: AbortSignal.timeout(30_000),
  })

  if (!response.ok) {
    const responseText = await response.text()
    throw new Error(`HTTP ${response.status}: ${responseText}`)
  }

  const responseText = await response.text()
  const data = responseText && response.headers.get("content-type")?.includes("application/json") ? JSON.parse(responseText) : responseText

  console.log(data)
}

main().catch(error => {
  console.error(error)
  process.exitCode = 1
})
Python
import json
import requests

url = "https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Idempotency-Key": "product-123-description-v1",
}
payload = json.loads("{\n  \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}")

response = requests.request(
    "POST",
    url,
    headers=headers,
    json=payload,
    timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2) if response.content and "application/json" in response.headers.get("Content-Type", "") else response.text)
PHP
<?php

$curl = curl_init('https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents');

if ($curl === false) {
    throw new RuntimeException('Unable to initialize cURL');
}

curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_API_KEY',
        'Accept: application/json',
        'Content-Type: application/json',
        'Idempotency-Key: product-123-description-v1',
    ],
    CURLOPT_POSTFIELDS => '{
  "title": "Ceramic coffee mug, 350 ml, dishwasher safe",
  "language": "en",
  "word_count": 400
}',
]);

$response = curl_exec($curl);

if ($response === false) {
    $message = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException('Network error: ' . $message);
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("HTTP $status: $response");
}

if ($response !== '' && str_contains($contentType, 'application/json')) {
    print_r(json_decode($response, true, 512, JSON_THROW_ON_ERROR));
} else {
    echo $response;
}
Go
package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
	"time"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
	defer cancel()

	request, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents", strings.NewReader("{\n  \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}"))
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	request.Header.Set("Accept", "application/json")
	request.Header.Set("Content-Type", "application/json")
	request.Header.Set("Idempotency-Key", "product-123-description-v1")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
		errorBody, readErr := io.ReadAll(response.Body)
		if readErr != nil {
			panic(readErr)
		}
		panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
	}

	if _, err := io.Copy(os.Stdout, response.Body); err != nil {
		panic(err)
	}
}
Google Apps Script
function callLabrikaPublicAPI() {
  const response = UrlFetchApp.fetch("https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents", {
    method: "post",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
      "Idempotency-Key": "product-123-description-v1",
    },
    payload: "{\n  \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}",
    followRedirects: false,
    muteHttpExceptions: true,
  });
  const status = response.getResponseCode();
  if (status < 200 || status >= 300) {
    throw new Error('HTTP ' + status + ': ' + response.getContentText());
  }
  Logger.log(response.getContentText());
}
GET /public-api/v1/ai-writer/product-descriptions/documents/{document_id}

For pending, repeat GET after retry_after_seconds (normally 10 seconds). For success, the response includes content (HTML), title, description, h1, actual_words, and credits_spent. For error, read error_code; credits_spent is 0.

curl
curl --fail-with-body --silent --show-error --location \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Accept: application/json' \
  'https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID", {
    method: "GET",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
    },
    signal: AbortSignal.timeout(30_000),
  })

  if (!response.ok) {
    const responseText = await response.text()
    throw new Error(`HTTP ${response.status}: ${responseText}`)
  }

  const responseText = await response.text()
  const data = responseText && response.headers.get("content-type")?.includes("application/json") ? JSON.parse(responseText) : responseText

  console.log(data)
}

main().catch(error => {
  console.error(error)
  process.exitCode = 1
})
Python
import json
import requests

url = "https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Accept": "application/json",
}

response = requests.request(
    "GET",
    url,
    headers=headers,
    timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2) if response.content and "application/json" in response.headers.get("Content-Type", "") else response.text)
PHP
<?php

$curl = curl_init('https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID');

if ($curl === false) {
    throw new RuntimeException('Unable to initialize cURL');
}

curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_API_KEY',
        'Accept: application/json',
    ],
]);

$response = curl_exec($curl);

if ($response === false) {
    $message = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException('Network error: ' . $message);
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("HTTP $status: $response");
}

if ($response !== '' && str_contains($contentType, 'application/json')) {
    print_r(json_decode($response, true, 512, JSON_THROW_ON_ERROR));
} else {
    echo $response;
}
Go
package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"os"
	"time"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
	defer cancel()

	request, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID", nil)
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_API_KEY")
	request.Header.Set("Accept", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
		errorBody, readErr := io.ReadAll(response.Body)
		if readErr != nil {
			panic(readErr)
		}
		panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
	}

	if _, err := io.Copy(os.Stdout, response.Body); err != nil {
		panic(err)
	}
}
Google Apps Script
function callLabrikaPublicAPI() {
  const response = UrlFetchApp.fetch("https://app.labrika.com/public-api/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID", {
    method: "get",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Accept": "application/json",
    },
    followRedirects: false,
    muteHttpExceptions: true,
  });
  const status = response.getResponseCode();
  if (status < 200 || status >= 300) {
    throw new Error('HTTP ' + status + ': ' + response.getContentText());
  }
  Logger.log(response.getContentText());
}
If the POST response is lost, retry with the same API key, Idempotency-Key, and unchanged body. The saved response is returned for 24 hours. A different body or an unfinished request returns HTTP 409. After an insufficient-credit response, add credits and use a new key.
product_not_recognized: clarify the product name and features. product_description_failed: generation failed. A known recognition failure may return HTTP 422 immediately; identical unrecognized products are cached for 7 days. A new key does not bypass this cache.
AI credits are reserved when generation starts. On success, credits_spent reports actual usage and unused reserved credits are returned. Failed generation does not spend credits.

Before using AI output, check the facts, company or product name, language and consistency with your inputs. Read generated HTML before publication. Technical success does not replace a content review.

Back to contents

API sandbox: testing an integration — Product descriptions

This guide applies to the test environment. Use a TEST key and /public-api-test/v1 throughout. The examples simulate results; they do not run live generation or charge the production account.

Generate catalog product descriptions from a product name and its features. The API returns HTML content, a page title, a meta description, and H1. Generation runs in the background: estimate the cost, create a document, then retrieve the result by its identifier.

All three fields are required in the JSON body of both POST requests. Send Content-Type: application/json. The body limit is 16 KiB. Creation requires ai-product-descriptions:write; estimation and reading the result require ai-product-descriptions:read.

Parameter Description
title · string Product name and key features: 1–256 characters. Include the model, material, size, or intended use to help identify the product.
language · string A language code from the reference below. This field determines the output language.
word_count · integer Parameter values and target lengths: 400 → 400–600 words; 600 → 600–800 words; 800 → 800–1200 words. The actual word count is returned in actual_words.

Supported languages

Use en to generate an English description. The accepted language codes are listed in ProductDescriptionRequest.

POST /public-api-test/v1/ai-writer/product-descriptions/cost

Estimates the cost without starting generation or spending credits. The response contains cost, total_credits, remaining_credits, and has_enough_credits. Check has_enough_credits before creating the document; an estimate does not reserve the balance.

curl
curl --fail-with-body --silent --show-error --location \
  --request POST \
  --header 'Authorization: Bearer YOUR_TEST_API_KEY' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{
  "title": "Ceramic coffee mug, 350 ml, dishwasher safe",
  "language": "en",
  "word_count": 400
}' \
  'https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/cost'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/cost", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_TEST_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      "title": "Ceramic coffee mug, 350 ml, dishwasher safe",
      "language": "en",
      "word_count": 400
    }),
    signal: AbortSignal.timeout(30_000),
  })

  if (!response.ok) {
    const responseText = await response.text()
    throw new Error(`HTTP ${response.status}: ${responseText}`)
  }

  const responseText = await response.text()
  const data = responseText && response.headers.get("content-type")?.includes("application/json") ? JSON.parse(responseText) : responseText

  console.log(data)
}

main().catch(error => {
  console.error(error)
  process.exitCode = 1
})
Python
import json
import requests

url = "https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/cost"
headers = {
    "Authorization": "Bearer YOUR_TEST_API_KEY",
    "Accept": "application/json",
    "Content-Type": "application/json",
}
payload = json.loads("{\n  \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}")

response = requests.request(
    "POST",
    url,
    headers=headers,
    json=payload,
    timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2) if response.content and "application/json" in response.headers.get("Content-Type", "") else response.text)
PHP
<?php

$curl = curl_init('https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/cost');

if ($curl === false) {
    throw new RuntimeException('Unable to initialize cURL');
}

curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_TEST_API_KEY',
        'Accept: application/json',
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => '{
  "title": "Ceramic coffee mug, 350 ml, dishwasher safe",
  "language": "en",
  "word_count": 400
}',
]);

$response = curl_exec($curl);

if ($response === false) {
    $message = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException('Network error: ' . $message);
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("HTTP $status: $response");
}

if ($response !== '' && str_contains($contentType, 'application/json')) {
    print_r(json_decode($response, true, 512, JSON_THROW_ON_ERROR));
} else {
    echo $response;
}
Go
package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
	"time"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
	defer cancel()

	request, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/cost", strings.NewReader("{\n  \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}"))
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_TEST_API_KEY")
	request.Header.Set("Accept", "application/json")
	request.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
		errorBody, readErr := io.ReadAll(response.Body)
		if readErr != nil {
			panic(readErr)
		}
		panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
	}

	if _, err := io.Copy(os.Stdout, response.Body); err != nil {
		panic(err)
	}
}
Google Apps Script
function callLabrikaPublicAPI() {
  const response = UrlFetchApp.fetch("https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/cost", {
    method: "post",
    headers: {
      "Authorization": "Bearer YOUR_TEST_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
    },
    payload: "{\n  \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}",
    followRedirects: false,
    muteHttpExceptions: true,
  });
  const status = response.getResponseCode();
  if (status < 200 || status >= 300) {
    throw new Error('HTTP ' + status + ': ' + response.getContentText());
  }
  Logger.log(response.getContentText());
}
POST /public-api-test/v1/ai-writer/product-descriptions/documents

Starts generation. Send a unique Idempotency-Key for each new document. HTTP 202 returns document_id, status, cost, and has_enough_credits. Save document_id to retrieve the result.

curl
curl --fail-with-body --silent --show-error --location \
  --request POST \
  --header 'Authorization: Bearer YOUR_TEST_API_KEY' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: product-123-description-v1' \
  --data '{
  "title": "Ceramic coffee mug, 350 ml, dishwasher safe",
  "language": "en",
  "word_count": 400
}' \
  'https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_TEST_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
      "Idempotency-Key": "product-123-description-v1",
    },
    body: JSON.stringify({
      "title": "Ceramic coffee mug, 350 ml, dishwasher safe",
      "language": "en",
      "word_count": 400
    }),
    signal: AbortSignal.timeout(30_000),
  })

  if (!response.ok) {
    const responseText = await response.text()
    throw new Error(`HTTP ${response.status}: ${responseText}`)
  }

  const responseText = await response.text()
  const data = responseText && response.headers.get("content-type")?.includes("application/json") ? JSON.parse(responseText) : responseText

  console.log(data)
}

main().catch(error => {
  console.error(error)
  process.exitCode = 1
})
Python
import json
import requests

url = "https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents"
headers = {
    "Authorization": "Bearer YOUR_TEST_API_KEY",
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Idempotency-Key": "product-123-description-v1",
}
payload = json.loads("{\n  \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}")

response = requests.request(
    "POST",
    url,
    headers=headers,
    json=payload,
    timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2) if response.content and "application/json" in response.headers.get("Content-Type", "") else response.text)
PHP
<?php

$curl = curl_init('https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents');

if ($curl === false) {
    throw new RuntimeException('Unable to initialize cURL');
}

curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_TEST_API_KEY',
        'Accept: application/json',
        'Content-Type: application/json',
        'Idempotency-Key: product-123-description-v1',
    ],
    CURLOPT_POSTFIELDS => '{
  "title": "Ceramic coffee mug, 350 ml, dishwasher safe",
  "language": "en",
  "word_count": 400
}',
]);

$response = curl_exec($curl);

if ($response === false) {
    $message = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException('Network error: ' . $message);
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("HTTP $status: $response");
}

if ($response !== '' && str_contains($contentType, 'application/json')) {
    print_r(json_decode($response, true, 512, JSON_THROW_ON_ERROR));
} else {
    echo $response;
}
Go
package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
	"time"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
	defer cancel()

	request, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents", strings.NewReader("{\n  \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}"))
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_TEST_API_KEY")
	request.Header.Set("Accept", "application/json")
	request.Header.Set("Content-Type", "application/json")
	request.Header.Set("Idempotency-Key", "product-123-description-v1")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
		errorBody, readErr := io.ReadAll(response.Body)
		if readErr != nil {
			panic(readErr)
		}
		panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
	}

	if _, err := io.Copy(os.Stdout, response.Body); err != nil {
		panic(err)
	}
}
Google Apps Script
function callLabrikaPublicAPI() {
  const response = UrlFetchApp.fetch("https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents", {
    method: "post",
    headers: {
      "Authorization": "Bearer YOUR_TEST_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
      "Idempotency-Key": "product-123-description-v1",
    },
    payload: "{\n  \"title\": \"Ceramic coffee mug, 350 ml, dishwasher safe\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}",
    followRedirects: false,
    muteHttpExceptions: true,
  });
  const status = response.getResponseCode();
  if (status < 200 || status >= 300) {
    throw new Error('HTTP ' + status + ': ' + response.getContentText());
  }
  Logger.log(response.getContentText());
}
GET /public-api-test/v1/ai-writer/product-descriptions/documents/{document_id}

For pending, repeat GET after retry_after_seconds (normally 10 seconds). For success, the response includes content (HTML), title, description, h1, actual_words, and credits_spent. For error, read error_code; credits_spent is 0.

curl
curl --fail-with-body --silent --show-error --location \
  --header 'Authorization: Bearer YOUR_TEST_API_KEY' \
  --header 'Accept: application/json' \
  'https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID", {
    method: "GET",
    headers: {
      "Authorization": "Bearer YOUR_TEST_API_KEY",
      "Accept": "application/json",
    },
    signal: AbortSignal.timeout(30_000),
  })

  if (!response.ok) {
    const responseText = await response.text()
    throw new Error(`HTTP ${response.status}: ${responseText}`)
  }

  const responseText = await response.text()
  const data = responseText && response.headers.get("content-type")?.includes("application/json") ? JSON.parse(responseText) : responseText

  console.log(data)
}

main().catch(error => {
  console.error(error)
  process.exitCode = 1
})
Python
import json
import requests

url = "https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID"
headers = {
    "Authorization": "Bearer YOUR_TEST_API_KEY",
    "Accept": "application/json",
}

response = requests.request(
    "GET",
    url,
    headers=headers,
    timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2) if response.content and "application/json" in response.headers.get("Content-Type", "") else response.text)
PHP
<?php

$curl = curl_init('https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID');

if ($curl === false) {
    throw new RuntimeException('Unable to initialize cURL');
}

curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_TEST_API_KEY',
        'Accept: application/json',
    ],
]);

$response = curl_exec($curl);

if ($response === false) {
    $message = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException('Network error: ' . $message);
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("HTTP $status: $response");
}

if ($response !== '' && str_contains($contentType, 'application/json')) {
    print_r(json_decode($response, true, 512, JSON_THROW_ON_ERROR));
} else {
    echo $response;
}
Go
package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"os"
	"time"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
	defer cancel()

	request, err := http.NewRequestWithContext(ctx, http.MethodGet, "https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID", nil)
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_TEST_API_KEY")
	request.Header.Set("Accept", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
		errorBody, readErr := io.ReadAll(response.Body)
		if readErr != nil {
			panic(readErr)
		}
		panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
	}

	if _, err := io.Copy(os.Stdout, response.Body); err != nil {
		panic(err)
	}
}
Google Apps Script
function callLabrikaPublicAPI() {
  const response = UrlFetchApp.fetch("https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents/DOCUMENT_ID", {
    method: "get",
    headers: {
      "Authorization": "Bearer YOUR_TEST_API_KEY",
      "Accept": "application/json",
    },
    followRedirects: false,
    muteHttpExceptions: true,
  });
  const status = response.getResponseCode();
  if (status < 200 || status >= 300) {
    throw new Error('HTTP ' + status + ': ' + response.getContentText());
  }
  Logger.log(response.getContentText());
}
If the POST response is lost, retry with the same API key, Idempotency-Key, and unchanged body. The saved response is returned for 24 hours. A different body or an unfinished request returns HTTP 409. After an insufficient-credit response, add credits and use a new key.
product_not_recognized: clarify the product name and features. product_description_failed: generation failed. A known recognition failure may return HTTP 422 immediately; identical unrecognized products are cached for 7 days. A new key does not bypass this cache.
AI credits are reserved when generation starts. On success, credits_spent reports actual usage and unused reserved credits are returned. Failed generation does not spend credits.

In test mode, use the following title values to reproduce errors. Use a new Idempotency-Key for each separate scenario.

title Result
sandbox:product_not_recognized Immediate HTTP 422
sandbox:async_product_not_recognized pending, then error product_not_recognized
sandbox:product_description_failed pending, then error product_description_failed
curl
curl --fail-with-body --silent --show-error --location \
  --request POST \
  --header 'Authorization: Bearer YOUR_TEST_API_KEY' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --header 'Idempotency-Key: sandbox-product-not-recognized-v1' \
  --data '{
  "title": "sandbox:product_not_recognized",
  "language": "en",
  "word_count": 400
}' \
  'https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents'
JavaScript
async function main () {
  const response = await fetch("https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents", {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_TEST_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
      "Idempotency-Key": "sandbox-product-not-recognized-v1",
    },
    body: JSON.stringify({
      "title": "sandbox:product_not_recognized",
      "language": "en",
      "word_count": 400
    }),
    signal: AbortSignal.timeout(30_000),
  })

  if (!response.ok) {
    const responseText = await response.text()
    throw new Error(`HTTP ${response.status}: ${responseText}`)
  }

  const responseText = await response.text()
  const data = responseText && response.headers.get("content-type")?.includes("application/json") ? JSON.parse(responseText) : responseText

  console.log(data)
}

main().catch(error => {
  console.error(error)
  process.exitCode = 1
})
Python
import json
import requests

url = "https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents"
headers = {
    "Authorization": "Bearer YOUR_TEST_API_KEY",
    "Accept": "application/json",
    "Content-Type": "application/json",
    "Idempotency-Key": "sandbox-product-not-recognized-v1",
}
payload = json.loads("{\n  \"title\": \"sandbox:product_not_recognized\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}")

response = requests.request(
    "POST",
    url,
    headers=headers,
    json=payload,
    timeout=30,
)
response.raise_for_status()
print(json.dumps(response.json(), ensure_ascii=False, indent=2) if response.content and "application/json" in response.headers.get("Content-Type", "") else response.text)
PHP
<?php

$curl = curl_init('https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents');

if ($curl === false) {
    throw new RuntimeException('Unable to initialize cURL');
}

curl_setopt_array($curl, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer YOUR_TEST_API_KEY',
        'Accept: application/json',
        'Content-Type: application/json',
        'Idempotency-Key: sandbox-product-not-recognized-v1',
    ],
    CURLOPT_POSTFIELDS => '{
  "title": "sandbox:product_not_recognized",
  "language": "en",
  "word_count": 400
}',
]);

$response = curl_exec($curl);

if ($response === false) {
    $message = curl_error($curl);
    curl_close($curl);
    throw new RuntimeException('Network error: ' . $message);
}

$status = curl_getinfo($curl, CURLINFO_RESPONSE_CODE);
$contentType = curl_getinfo($curl, CURLINFO_CONTENT_TYPE) ?: '';
curl_close($curl);

if ($status < 200 || $status >= 300) {
    throw new RuntimeException("HTTP $status: $response");
}

if ($response !== '' && str_contains($contentType, 'application/json')) {
    print_r(json_decode($response, true, 512, JSON_THROW_ON_ERROR));
} else {
    echo $response;
}
Go
package main

import (
	"context"
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
	"time"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 30 * time.Second)
	defer cancel()

	request, err := http.NewRequestWithContext(ctx, http.MethodPost, "https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents", strings.NewReader("{\n  \"title\": \"sandbox:product_not_recognized\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}"))
	if err != nil {
		panic(err)
	}

	request.Header.Set("Authorization", "Bearer YOUR_TEST_API_KEY")
	request.Header.Set("Accept", "application/json")
	request.Header.Set("Content-Type", "application/json")
	request.Header.Set("Idempotency-Key", "sandbox-product-not-recognized-v1")

	client := &http.Client{Timeout: 30 * time.Second}
	response, err := client.Do(request)
	if err != nil {
		panic(err)
	}
	defer response.Body.Close()

	if response.StatusCode < http.StatusOK || response.StatusCode >= http.StatusMultipleChoices {
		errorBody, readErr := io.ReadAll(response.Body)
		if readErr != nil {
			panic(readErr)
		}
		panic(fmt.Sprintf("HTTP %d: %s", response.StatusCode, errorBody))
	}

	if _, err := io.Copy(os.Stdout, response.Body); err != nil {
		panic(err)
	}
}
Google Apps Script
function callLabrikaPublicAPI() {
  const response = UrlFetchApp.fetch("https://app.labrika.com/public-api-test/v1/ai-writer/product-descriptions/documents", {
    method: "post",
    headers: {
      "Authorization": "Bearer YOUR_TEST_API_KEY",
      "Accept": "application/json",
      "Content-Type": "application/json",
      "Idempotency-Key": "sandbox-product-not-recognized-v1",
    },
    payload: "{\n  \"title\": \"sandbox:product_not_recognized\",\n  \"language\": \"en\",\n  \"word_count\": 400\n}",
    followRedirects: false,
    muteHttpExceptions: true,
  });
  const status = response.getResponseCode();
  if (status < 200 || status >= 300) {
    throw new Error('HTTP ' + status + ': ' + response.getContentText());
  }
  Logger.log(response.getContentText());
}

Before using AI output, check the facts, company or product name, language and consistency with your inputs. Read generated HTML before publication. Technical success does not replace a content review.

Back to contents

API method reference — ProductDescriptions

Choose a method from the contents. Check its HTTP method, path, scopes, required parameters and request body. JSON blocks containing schema, properties and $ref describe the contract; do not send them as a ready-made request body. Request examples and response schemas are labelled separately.

Methods in this section

POST /public-api/v1/ai-writer/product-descriptions/cost

Requires the ai-product-descriptions:read key scope and the account permission public-api-product-descriptions.show. The test equivalent is available with a test key at /public-api-test/v1 with the same path suffix. The sandbox uses fixtures, without AI or real charges. An ordinary product name returns success; sandbox:product_not_recognized returns 422; sandbox:async_product_not_recognized and sandbox:product_description_failed return the corresponding error after pending. Test documents are available for 7 days or until the sandbox is reset, whichever comes first.

Related data models: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · ErrorResponse · ProductDescriptionCost · ProductDescriptionRequest

Request

JSON body up to 16384 bytes.

{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ProductDescriptionRequest"
      }
    }
  }
}

Responses

200

Current result; cost estimation does not reserve or spend credits.

{
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ProductDescriptionCost"
      }
    }
  }
}
default

Public API error. Rate-limit headers describe the limit actually checked: failed authentication attempts per IP for missing or invalid keys, or the applicable key/account limit after authentication. They may be absent for access blocks before rate-limit checks or when the limiter is unavailable. X-RateLimit-Reset is a Unix timestamp in seconds; Retry-After is a delay in seconds for 429.

{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

POST /public-api/v1/ai-writer/product-descriptions/documents

Requires the ai-product-descriptions:write key scope and the account permission public-api-product-descriptions.show. The test equivalent is available with a test key at /public-api-test/v1 with the same path suffix. The sandbox uses fixtures, without AI or real charges. An ordinary product name returns success; sandbox:product_not_recognized returns 422; sandbox:async_product_not_recognized and sandbox:product_description_failed return the corresponding error after pending. Test documents are available for 7 days or until the sandbox is reset, whichever comes first.

Related data models: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · ErrorResponse · ProductDescriptionCost · ProductDescriptionRejected · ProductDescriptionRequest · ProductDescriptionStart

Parameters

Idempotency-Key (header)

Required for paid generation. Replays the response for the same key, route and exact request body for 24 hours. A different body returns 409. Concurrent requests and uncertain launch outcomes remain blocked with 409; do not retry with a new key.

{
  "required": true,
  "schema": {
    "type": "string",
    "minLength": 1,
    "maxLength": 128,
    "pattern": "^[A-Za-z0-9._:-]+$"
  }
}

Request

JSON body up to 16384 bytes.

{
  "required": true,
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ProductDescriptionRequest"
      }
    }
  }
}

Responses

202

Generation accepted; cost is the reserved upper bound.

{
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ProductDescriptionStart"
      }
    }
  }
}
422

Insufficient credits or a cached product recognition failure from the last 7 days (error.code=product_not_recognized, credits_spent=0). Generation does not start. After changing the parameters or topping up the balance, use a new Idempotency-Key.

{
  "content": {
    "application/json": {
      "schema": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/ProductDescriptionCost"
          },
          {
            "$ref": "#/components/schemas/ProductDescriptionRejected"
          }
        ]
      }
    }
  }
}
409
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

GET /public-api/v1/ai-writer/product-descriptions/documents/{document_id}

Requires the ai-product-descriptions:read key scope and the account permission public-api-product-descriptions.show. The test equivalent is available with a test key at /public-api-test/v1 with the same path suffix. The sandbox uses fixtures, without AI or real charges. An ordinary product name returns success; sandbox:product_not_recognized returns 422; sandbox:async_product_not_recognized and sandbox:product_description_failed return the corresponding error after pending. Test documents are available for 7 days or until the sandbox is reset, whichever comes first.

Related data models: CacheControl · RateLimitLimit · RateLimitRemaining · RateLimitResetAt · RetryAfter · XRequestID · ErrorResponse · ProductDescriptionDocument

Parameters

document_id (path)
{
  "required": true,
  "schema": {
    "type": "string"
  }
}

Responses

200

State of the owner’s product description. Poll pending results after 10 seconds.

{
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ProductDescriptionDocument"
      }
    }
  }
}
default
{
  "headers": {
    "X-Request-ID": {
      "$ref": "#/components/headers/XRequestID"
    },
    "X-RateLimit-Limit": {
      "$ref": "#/components/headers/RateLimitLimit"
    },
    "X-RateLimit-Remaining": {
      "$ref": "#/components/headers/RateLimitRemaining"
    },
    "X-RateLimit-Reset": {
      "$ref": "#/components/headers/RateLimitResetAt"
    },
    "Cache-Control": {
      "$ref": "#/components/headers/CacheControl"
    },
    "Retry-After": {
      "$ref": "#/components/headers/RetryAfter"
    }
  },
  "content": {
    "application/json": {
      "schema": {
        "$ref": "#/components/schemas/ErrorResponse"
      }
    }
  }
}

Before using AI output, check the facts, company or product name, language and consistency with your inputs. Read generated HTML before publication. Technical success does not replace a content review.

Back to contents