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

# Quickstart

> Generate a pattern and order it as a product.

<Steps>
  <Step title="Get an API key">
    Create a key in [Arcade Studio](https://studio.arcade.ai/settings/api-keys) under **Settings → API keys**, then export it.

    ```bash theme={null}
    export ARCADE_API_KEY="your-api-key"
    ```
  </Step>

  <Step title="Generate a pattern">
    Send a prompt. The `requestId` makes the request safe to retry. Name your integration in the `User-Agent` header; see [Identify your client](/authentication#identify-your-client).

    <CodeGroup>
      ```bash cURL theme={null}
      curl --fail-with-body https://platform.arcade.ai/v1/patterns/create \
        -H "Authorization: Bearer $ARCADE_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "requestId": "linen-florals-1",
          "prompt": "Small blue and white block-print florals on natural linen"
        }'
      ```

      ```python Python theme={null}
      import json
      import os
      import urllib.request

      body = {
          "requestId": "linen-florals-1",
          "prompt": "Small blue and white block-print florals on natural linen"
      }
      request = urllib.request.Request(
          "https://platform.arcade.ai/v1/patterns/create",
          data=json.dumps(body).encode(),
          headers={
              "Authorization": f"Bearer {os.environ['ARCADE_API_KEY']}",
              "Content-Type": "application/json",
              "User-Agent": "your-app/1.0",
          },
          method="POST",
      )
      with urllib.request.urlopen(request) as response:
          print(json.dumps(json.load(response), indent=2))
      ```

      ```javascript JavaScript theme={null}
      const apiKey = process.env.ARCADE_API_KEY;
      if (!apiKey) throw new Error("Set ARCADE_API_KEY");

      const response = await fetch("https://platform.arcade.ai/v1/patterns/create", {
        method: "POST",
        headers: {
          Authorization: `Bearer ${apiKey}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          "requestId": "linen-florals-1",
          "prompt": "Small blue and white block-print florals on natural linen"
        }),
      });
      if (!response.ok) {
        throw new Error(`HTTP ${response.status}: ${await response.text()}`);
      }
      console.log(await response.json());
      ```

      ```typescript TypeScript theme={null}
      type RequestBody = { requestId: string; prompt: string };

      const apiKey = process.env.ARCADE_API_KEY;
      if (!apiKey) throw new Error("Set ARCADE_API_KEY");

      const body: RequestBody = {
        "requestId": "linen-florals-1",
        "prompt": "Small blue and white block-print florals on natural linen"
      };
      const response = await fetch("https://platform.arcade.ai/v1/patterns/create", {
        method: "POST",
        headers: {
          Authorization: `Bearer ${apiKey}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        throw new Error(`HTTP ${response.status}: ${await response.text()}`);
      }
      console.log(await response.json());
      ```

      ```go Go theme={null}
      package main

      import (
          "fmt"
          "io"
          "log"
          "net/http"
          "os"
          "strings"
      )

      func main() {
          apiKey := os.Getenv("ARCADE_API_KEY")
          if apiKey == "" {
              log.Fatal("Set ARCADE_API_KEY")
          }

          request, err := http.NewRequest(http.MethodPost, "https://platform.arcade.ai/v1/patterns/create", strings.NewReader(`{
            "requestId": "linen-florals-1",
            "prompt": "Small blue and white block-print florals on natural linen"
          }`))
          if err != nil {
              log.Fatal(err)
          }
          request.Header.Set("Authorization", "Bearer "+apiKey)
          request.Header.Set("Content-Type", "application/json")

          response, err := http.DefaultClient.Do(request)
          if err != nil {
              log.Fatal(err)
          }
          defer response.Body.Close()
          body, err := io.ReadAll(response.Body)
          if err != nil {
              log.Fatal(err)
          }
          if response.StatusCode >= 400 {
              log.Fatalf("HTTP %s: %s", response.Status, body)
          }
          fmt.Println(string(body))
      }
      ```

      ```rust Rust theme={null}
      use serde_json::json;

      fn main() -> Result<(), Box<dyn std::error::Error>> {
          let response = reqwest::blocking::Client::new()
              .post("https://platform.arcade.ai/v1/patterns/create")
              .bearer_auth(std::env::var("ARCADE_API_KEY")?)
              .json(&json!({
                "requestId": "linen-florals-1",
                "prompt": "Small blue and white block-print florals on natural linen"
              }))
              .send()?
              .error_for_status()?;
          println!("{}", response.text()?);
          Ok(())
      }
      ```
    </CodeGroup>

    ```json theme={null}
    {
      "jobId": "3583f242-50ed-4250-94c2-c00ea25249dd",
      "kind": "pattern",
      "status": "running",
      "result": null
    }
    ```
  </Step>

  <Step title="Wait for the job">
    Poll the job until `status` is `succeeded` or `failed`. Generation takes a minute or two; if it fails, `error.message` says why.

    <CodeGroup>
      ```bash cURL theme={null}
      curl --fail-with-body https://platform.arcade.ai/v1/jobs/get \
        -H "Authorization: Bearer $ARCADE_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{ "jobId": "3583f242-50ed-4250-94c2-c00ea25249dd" }'
      ```

      ```python Python theme={null}
      import json
      import os
      import urllib.request

      body = {
          "jobId": "3583f242-50ed-4250-94c2-c00ea25249dd"
      }
      request = urllib.request.Request(
          "https://platform.arcade.ai/v1/jobs/get",
          data=json.dumps(body).encode(),
          headers={
              "Authorization": f"Bearer {os.environ['ARCADE_API_KEY']}",
              "Content-Type": "application/json",
              "User-Agent": "your-app/1.0",
          },
          method="POST",
      )
      with urllib.request.urlopen(request) as response:
          print(json.dumps(json.load(response), indent=2))
      ```

      ```javascript JavaScript theme={null}
      const apiKey = process.env.ARCADE_API_KEY;
      if (!apiKey) throw new Error("Set ARCADE_API_KEY");

      const response = await fetch("https://platform.arcade.ai/v1/jobs/get", {
        method: "POST",
        headers: {
          Authorization: `Bearer ${apiKey}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          "jobId": "3583f242-50ed-4250-94c2-c00ea25249dd"
        }),
      });
      if (!response.ok) {
        throw new Error(`HTTP ${response.status}: ${await response.text()}`);
      }
      console.log(await response.json());
      ```

      ```typescript TypeScript theme={null}
      type RequestBody = { jobId: string };

      const apiKey = process.env.ARCADE_API_KEY;
      if (!apiKey) throw new Error("Set ARCADE_API_KEY");

      const body: RequestBody = {
        "jobId": "3583f242-50ed-4250-94c2-c00ea25249dd"
      };
      const response = await fetch("https://platform.arcade.ai/v1/jobs/get", {
        method: "POST",
        headers: {
          Authorization: `Bearer ${apiKey}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        throw new Error(`HTTP ${response.status}: ${await response.text()}`);
      }
      console.log(await response.json());
      ```

      ```go Go theme={null}
      package main

      import (
          "fmt"
          "io"
          "log"
          "net/http"
          "os"
          "strings"
      )

      func main() {
          apiKey := os.Getenv("ARCADE_API_KEY")
          if apiKey == "" {
              log.Fatal("Set ARCADE_API_KEY")
          }

          request, err := http.NewRequest(http.MethodPost, "https://platform.arcade.ai/v1/jobs/get", strings.NewReader(`{
            "jobId": "3583f242-50ed-4250-94c2-c00ea25249dd"
          }`))
          if err != nil {
              log.Fatal(err)
          }
          request.Header.Set("Authorization", "Bearer "+apiKey)
          request.Header.Set("Content-Type", "application/json")

          response, err := http.DefaultClient.Do(request)
          if err != nil {
              log.Fatal(err)
          }
          defer response.Body.Close()
          body, err := io.ReadAll(response.Body)
          if err != nil {
              log.Fatal(err)
          }
          if response.StatusCode >= 400 {
              log.Fatalf("HTTP %s: %s", response.Status, body)
          }
          fmt.Println(string(body))
      }
      ```

      ```rust Rust theme={null}
      use serde_json::json;

      fn main() -> Result<(), Box<dyn std::error::Error>> {
          let response = reqwest::blocking::Client::new()
              .post("https://platform.arcade.ai/v1/jobs/get")
              .bearer_auth(std::env::var("ARCADE_API_KEY")?)
              .json(&json!({
                "jobId": "3583f242-50ed-4250-94c2-c00ea25249dd"
              }))
              .send()?
              .error_for_status()?;
          println!("{}", response.text()?);
          Ok(())
      }
      ```
    </CodeGroup>

    ```json theme={null}
    {
      "jobId": "3583f242-50ed-4250-94c2-c00ea25249dd",
      "kind": "pattern",
      "status": "succeeded",
      "result": { "patternId": "cmujgkfnk0004pc10nt3kghxd" }
    }
    ```
  </Step>

  <Step title="Create a product">
    Choose a category from `categories/list` and its options from `categories/get`; category IDs differ between production and staging. This example makes cotton dinner napkins in production.

    <CodeGroup>
      ```bash cURL theme={null}
      curl --fail-with-body https://platform.arcade.ai/v1/products/create \
        -H "Authorization: Bearer $ARCADE_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "requestId": "linen-florals-napkins-1",
          "patternId": "cmujgkfnk0004pc10nt3kghxd",
          "categoryId": "c314010b-e15a-4014-a376-9b8f4e973461",
          "selections": { "fabric": "cotton", "size": "20x20" }
        }'
      ```

      ```python Python theme={null}
      import json
      import os
      import urllib.request

      body = {
          "requestId": "linen-florals-napkins-1",
          "patternId": "cmujgkfnk0004pc10nt3kghxd",
          "categoryId": "c314010b-e15a-4014-a376-9b8f4e973461",
          "selections": {
              "fabric": "cotton",
              "size": "20x20"
          }
      }
      request = urllib.request.Request(
          "https://platform.arcade.ai/v1/products/create",
          data=json.dumps(body).encode(),
          headers={
              "Authorization": f"Bearer {os.environ['ARCADE_API_KEY']}",
              "Content-Type": "application/json",
              "User-Agent": "your-app/1.0",
          },
          method="POST",
      )
      with urllib.request.urlopen(request) as response:
          print(json.dumps(json.load(response), indent=2))
      ```

      ```javascript JavaScript theme={null}
      const apiKey = process.env.ARCADE_API_KEY;
      if (!apiKey) throw new Error("Set ARCADE_API_KEY");

      const response = await fetch("https://platform.arcade.ai/v1/products/create", {
        method: "POST",
        headers: {
          Authorization: `Bearer ${apiKey}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          "requestId": "linen-florals-napkins-1",
          "patternId": "cmujgkfnk0004pc10nt3kghxd",
          "categoryId": "c314010b-e15a-4014-a376-9b8f4e973461",
          "selections": {
            "fabric": "cotton",
            "size": "20x20"
          }
        }),
      });
      if (!response.ok) {
        throw new Error(`HTTP ${response.status}: ${await response.text()}`);
      }
      console.log(await response.json());
      ```

      ```typescript TypeScript theme={null}
      type RequestBody = { requestId: string; patternId: string; categoryId: string; selections: Record<string, string> };

      const apiKey = process.env.ARCADE_API_KEY;
      if (!apiKey) throw new Error("Set ARCADE_API_KEY");

      const body: RequestBody = {
        "requestId": "linen-florals-napkins-1",
        "patternId": "cmujgkfnk0004pc10nt3kghxd",
        "categoryId": "c314010b-e15a-4014-a376-9b8f4e973461",
        "selections": {
          "fabric": "cotton",
          "size": "20x20"
        }
      };
      const response = await fetch("https://platform.arcade.ai/v1/products/create", {
        method: "POST",
        headers: {
          Authorization: `Bearer ${apiKey}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        throw new Error(`HTTP ${response.status}: ${await response.text()}`);
      }
      console.log(await response.json());
      ```

      ```go Go theme={null}
      package main

      import (
          "fmt"
          "io"
          "log"
          "net/http"
          "os"
          "strings"
      )

      func main() {
          apiKey := os.Getenv("ARCADE_API_KEY")
          if apiKey == "" {
              log.Fatal("Set ARCADE_API_KEY")
          }

          request, err := http.NewRequest(http.MethodPost, "https://platform.arcade.ai/v1/products/create", strings.NewReader(`{
            "requestId": "linen-florals-napkins-1",
            "patternId": "cmujgkfnk0004pc10nt3kghxd",
            "categoryId": "c314010b-e15a-4014-a376-9b8f4e973461",
            "selections": {
              "fabric": "cotton",
              "size": "20x20"
            }
          }`))
          if err != nil {
              log.Fatal(err)
          }
          request.Header.Set("Authorization", "Bearer "+apiKey)
          request.Header.Set("Content-Type", "application/json")

          response, err := http.DefaultClient.Do(request)
          if err != nil {
              log.Fatal(err)
          }
          defer response.Body.Close()
          body, err := io.ReadAll(response.Body)
          if err != nil {
              log.Fatal(err)
          }
          if response.StatusCode >= 400 {
              log.Fatalf("HTTP %s: %s", response.Status, body)
          }
          fmt.Println(string(body))
      }
      ```

      ```rust Rust theme={null}
      use serde_json::json;

      fn main() -> Result<(), Box<dyn std::error::Error>> {
          let response = reqwest::blocking::Client::new()
              .post("https://platform.arcade.ai/v1/products/create")
              .bearer_auth(std::env::var("ARCADE_API_KEY")?)
              .json(&json!({
                "requestId": "linen-florals-napkins-1",
                "patternId": "cmujgkfnk0004pc10nt3kghxd",
                "categoryId": "c314010b-e15a-4014-a376-9b8f4e973461",
                "selections": {
                  "fabric": "cotton",
                  "size": "20x20"
                }
              }))
              .send()?
              .error_for_status()?;
          println!("{}", response.text()?);
          Ok(())
      }
      ```
    </CodeGroup>

    Product builds also return a job. When it succeeds, `result.productId` is your product.
  </Step>

  <Step title="Order it">
    Create a checkout, then open `checkoutUrl` to pay.

    <CodeGroup>
      ```bash cURL theme={null}
      curl --fail-with-body https://platform.arcade.ai/v1/checkouts/create \
        -H "Authorization: Bearer $ARCADE_API_KEY" \
        -H "Content-Type: application/json" \
        -d '{
          "requestId": "linen-florals-checkout-1",
          "lines": [{ "productId": "1cda0369-36f4-44ca-aae2-9d60e788a291", "quantity": 10 }]
        }'
      ```

      ```python Python theme={null}
      import json
      import os
      import urllib.request

      body = {
          "requestId": "linen-florals-checkout-1",
          "lines": [
              {
                  "productId": "1cda0369-36f4-44ca-aae2-9d60e788a291",
                  "quantity": 10
              }
          ]
      }
      request = urllib.request.Request(
          "https://platform.arcade.ai/v1/checkouts/create",
          data=json.dumps(body).encode(),
          headers={
              "Authorization": f"Bearer {os.environ['ARCADE_API_KEY']}",
              "Content-Type": "application/json",
              "User-Agent": "your-app/1.0",
          },
          method="POST",
      )
      with urllib.request.urlopen(request) as response:
          print(json.dumps(json.load(response), indent=2))
      ```

      ```javascript JavaScript theme={null}
      const apiKey = process.env.ARCADE_API_KEY;
      if (!apiKey) throw new Error("Set ARCADE_API_KEY");

      const response = await fetch("https://platform.arcade.ai/v1/checkouts/create", {
        method: "POST",
        headers: {
          Authorization: `Bearer ${apiKey}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify({
          "requestId": "linen-florals-checkout-1",
          "lines": [
            {
              "productId": "1cda0369-36f4-44ca-aae2-9d60e788a291",
              "quantity": 10
            }
          ]
        }),
      });
      if (!response.ok) {
        throw new Error(`HTTP ${response.status}: ${await response.text()}`);
      }
      console.log(await response.json());
      ```

      ```typescript TypeScript theme={null}
      type RequestBody = { requestId: string; lines: Array<{ productId: string; quantity: number }> };

      const apiKey = process.env.ARCADE_API_KEY;
      if (!apiKey) throw new Error("Set ARCADE_API_KEY");

      const body: RequestBody = {
        "requestId": "linen-florals-checkout-1",
        "lines": [
          {
            "productId": "1cda0369-36f4-44ca-aae2-9d60e788a291",
            "quantity": 10
          }
        ]
      };
      const response = await fetch("https://platform.arcade.ai/v1/checkouts/create", {
        method: "POST",
        headers: {
          Authorization: `Bearer ${apiKey}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        throw new Error(`HTTP ${response.status}: ${await response.text()}`);
      }
      console.log(await response.json());
      ```

      ```go Go theme={null}
      package main

      import (
          "fmt"
          "io"
          "log"
          "net/http"
          "os"
          "strings"
      )

      func main() {
          apiKey := os.Getenv("ARCADE_API_KEY")
          if apiKey == "" {
              log.Fatal("Set ARCADE_API_KEY")
          }

          request, err := http.NewRequest(http.MethodPost, "https://platform.arcade.ai/v1/checkouts/create", strings.NewReader(`{
            "requestId": "linen-florals-checkout-1",
            "lines": [
              {
                "productId": "1cda0369-36f4-44ca-aae2-9d60e788a291",
                "quantity": 10
              }
            ]
          }`))
          if err != nil {
              log.Fatal(err)
          }
          request.Header.Set("Authorization", "Bearer "+apiKey)
          request.Header.Set("Content-Type", "application/json")

          response, err := http.DefaultClient.Do(request)
          if err != nil {
              log.Fatal(err)
          }
          defer response.Body.Close()
          body, err := io.ReadAll(response.Body)
          if err != nil {
              log.Fatal(err)
          }
          if response.StatusCode >= 400 {
              log.Fatalf("HTTP %s: %s", response.Status, body)
          }
          fmt.Println(string(body))
      }
      ```

      ```rust Rust theme={null}
      use serde_json::json;

      fn main() -> Result<(), Box<dyn std::error::Error>> {
          let response = reqwest::blocking::Client::new()
              .post("https://platform.arcade.ai/v1/checkouts/create")
              .bearer_auth(std::env::var("ARCADE_API_KEY")?)
              .json(&json!({
                "requestId": "linen-florals-checkout-1",
                "lines": [
                  {
                    "productId": "1cda0369-36f4-44ca-aae2-9d60e788a291",
                    "quantity": 10
                  }
                ]
              }))
              .send()?
              .error_for_status()?;
          println!("{}", response.text()?);
          Ok(())
      }
      ```
    </CodeGroup>

    ```json theme={null}
    {
      "checkoutId": "1129729917083",
      "checkoutUrl": "https://checkout.arcade.ai/checkouts/..."
    }
    ```

    After payment, `orders/get` with the `checkoutId` returns the order.
  </Step>
</Steps>
