Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.arcuserp.com/llms.txt

Use this file to discover all available pages before exploring further.

Installation

go get github.com/arcuserp/sdk-go
Requires Go 1.21 or later.

Quick start

package main

import (
    "context"
    "fmt"
    "os"

    arcus "github.com/arcuserp/sdk-go"
)

func main() {
    client := arcus.NewClient(
        os.Getenv("ARCUS_API_KEY"),
        arcus.WithEntityID(os.Getenv("ARCUS_ENTITY_ID")),
    )

    // List accounts
    accounts, err := client.Accounts.List(context.Background(), &arcus.AccountListParams{
        Limit: arcus.Int(10),
    })
    if err != nil {
        panic(err)
    }
    for _, a := range accounts.Data {
        fmt.Println(a.Name)
    }

    // Create a sales order
    order, err := client.Orders.Create(
        context.Background(),
        &arcus.OrderCreateParams{
            DocumentType: arcus.String("sales_order"),
            AccountID:    arcus.String("acc_01H..."),
            LineItems: []arcus.LineItemParam{
                {ProductID: "prod_01H...", Quantity: 5, UnitPrice: 29.99},
            },
        },
        arcus.WithIdempotencyKey(uuid.New().String()),
    )
    if err != nil {
        panic(err)
    }
    fmt.Println(order.ID)
}

Configuration

client := arcus.NewClient(
    os.Getenv("ARCUS_API_KEY"),
    arcus.WithEntityID(os.Getenv("ARCUS_ENTITY_ID")),

    // Optional
    arcus.WithBaseURL("https://api.arcuserp.com/v1"), // optional; defaults to https://api.arcuserp.com/v1
    arcus.WithAPIVersion("2026-05-01"),
    arcus.WithMaxRetries(3),
    arcus.WithTimeout(30 * time.Second),
    arcus.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
)

Auto-pagination

params := &arcus.OrderListParams{Limit: arcus.Int(100)}
iter := client.Orders.List(context.Background(), params)
for iter.Next() {
    order := iter.Order()
    fmt.Println(order.ID, order.DocumentType)
}
if err := iter.Err(); err != nil {
    panic(err)
}

Error handling

import arcus "github.com/arcuserp/sdk-go"

order, err := client.Orders.Get(context.Background(), "ord_invalid", nil)
if err != nil {
    var apiErr *arcus.APIError
    if errors.As(err, &apiErr) {
        fmt.Println(apiErr.Code)       // machine-readable code
        fmt.Println(apiErr.Hint)       // human-readable hint
        fmt.Println(apiErr.RequestID)  // for Arcus support
        fmt.Println(apiErr.StatusCode) // HTTP status

        if apiErr.StatusCode == 429 {
            // SDK auto-retried; exhausted retries
            fmt.Println("Rate limit exhausted")
        }
    }
}

Webhooks

import (
    "io"
    "net/http"

    arcus "github.com/arcuserp/sdk-go"
)

func webhookHandler(w http.ResponseWriter, r *http.Request) {
    body, err := io.ReadAll(r.Body)
    if err != nil {
        http.Error(w, "read error", http.StatusBadRequest)
        return
    }

    event, err := arcus.ConstructEvent(
        body,
        r.Header.Get("Arcus-Signature"),
        os.Getenv("ARCUS_WEBHOOK_SECRET"),
    )
    if err != nil {
        http.Error(w, "signature verification failed", http.StatusBadRequest)
        return
    }

    switch event.Type {
    case "order.confirmed":
        fmt.Printf("Order confirmed: %s\n", event.Data.Object["id"])
    case "payment.received":
        fmt.Printf("Payment received: %s\n", event.Data.Object["id"])
    }

    w.WriteHeader(http.StatusOK)
}

Source

Generated from arcus-api-core/openapi/arcus-api-v1.yaml via Speakeasy. Source: arcus-erp-aws/sdks/go.