> ## Documentation Index
> Fetch the complete documentation index at: https://docs.algure.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Via API

> Programmatic integration flow

## Overview

Use this mode when you want system-to-system integration from ERP, WMS, or custom services.

## Configure API Credentials

Visit the [API Quickstart](/api-reference/quickstart) to configure API credentials and make your first request.

## Import Flow

<Steps>
  <Step title="Create an import">
    Create a new import to get a temporary `importId`.

    ```javascript theme={"dark"}
    const baseUrl = "https://api.algure.com/v1";
    const authorization = "Basic <base64(clientId:clientSecret)>";

    const createImportRes = await fetch(`${baseUrl}/products/import`, {
      method: "POST",
      headers: { Authorization: authorization },
    });

    if (!createImportRes.ok) {
      throw new Error(`Create import failed: ${createImportRes.status}`);
    }

    const productImport = await createImportRes.json();
    console.log(productImport); // { id: "...", expiresAt: "..." }
    ```
  </Step>

  <Step title="Build the CSV feed">
    Build a UTF-8 CSV string from your source data using the required feed columns.

    ```javascript theme={"dark"}
    function buildAlgureCsv(rows) {
      const header = [
        "code",
        "description",
        "stock",
        "warehouseCode",
        "locationCode",
        "locationPriority",
        "costPrice",
        "packagingUnit",
        "lot",
      ].join(",");

      const lines = rows.map((r) =>
        [
          r.code,
          r.description,
          r.stock,
          r.warehouseCode,
          r.locationCode,
          r.locationPriority ?? "",
          r.costPrice,
          r.packagingUnit,
          r.lot ?? "",
        ].join(",")
      );

      return [header, ...lines].join("\n");
    }
    ```
  </Step>

  <Step title="Upload the feed">
    Upload the CSV body using the `importId` from step 1.

    ```javascript theme={"dark"}
    const csv = buildAlgureCsv(rows);

    const uploadRes = await fetch(`${baseUrl}/products/import/${productImport.id}`, {
      method: "PUT",
      headers: {
        Authorization: authorization,
        "Content-Type": "text/csv",
      },
      body: csv,
    });

    if (uploadRes.status !== 201) {
      throw new Error(`Upload failed: ${uploadRes.status}`);
    }

    console.log("Feed accepted and queued");
    ```
  </Step>

  <Step title="Wait for asynchronous processing">
    Upload acceptance means the file was queued. Processing and row-level validation happen asynchronously.
  </Step>
</Steps>

## Operational Notes

* Recommended workflow: create a new import for each upload
* Import validity window is short (default: 30 minutes)
* Upload size limit is 10 MB
* Accepted upload content types: `text/csv` (recommended) and `text/plain`
* Standard integration feed format is UTF-8 CSV

<Card icon="square-code" horizontal href="/api-reference" title="API Reference">
  Learn about all available Algure APIs
</Card>
