tracore

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 11 Imported by: 0

README

sdk-go

Built against Tracore API v0.6.0.

Official Go SDK for the Tracore API — schema-driven document-to-JSON extraction.

go get github.com/tracore-io/sdk-go@latest
import tracore "github.com/tracore-io/sdk-go"

Quick start

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	tracore "github.com/tracore-io/sdk-go"
)

func main() {
	client, err := tracore.New(tracore.ClientOptions{
		APIKey: os.Getenv("TRACORE_API_KEY"),
	})
	if err != nil {
		log.Fatal(err)
	}
	ctx := context.Background()

	// Create a workspace.
	ws, err := client.Workspaces.Create(ctx, tracore.CreateWorkspaceRequest{Name: "My Workspace"})
	if err != nil {
		log.Fatal(err)
	}

	// Define a schema.
	if _, err := client.Schemas.Create(ctx, ws.Slug, tracore.CreateSchemaFamilyRequest{
		SchemaKey: "invoice",
		Name:      "Invoice Schema",
		Definition: map[string]interface{}{
			"type": "object",
			"properties": map[string]interface{}{
				"invoiceNumber": map[string]interface{}{"type": "string"},
				"total":         map[string]interface{}{"type": "number"},
			},
		},
	}); err != nil {
		log.Fatal(err)
	}

	// Extract from a file, polling until the run completes.
	f, err := os.Open("invoice.pdf")
	if err != nil {
		log.Fatal(err)
	}
	defer f.Close()

	run, err := client.Extract(ctx, ws.Slug, "invoice",
		tracore.ExtractInput{File: f, FileName: "invoice.pdf"},
		&tracore.ExtractOptions{Poll: true})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(run.Status, run.ExtractedData)
}

Resources

  • client.Workspaces — manage workspaces
  • client.Schemas — manage schema families and versions
  • client.Documents — upload, download, and manage documents
  • client.Runs — list, fetch, and poll extraction runs
  • client.Webhooks — configure webhook endpoints and inspect deliveries
  • client.Environments — manage environments
  • client.User.ProviderKeys — manage the user's AI provider keys (BYOK)
  • client.Extract(...) — one-call extract (by document ID or inline upload), with optional polling
  • client.ExtractAsync(...) — fire-and-forget extract returning the 202 accepted envelope (runId, pending)

Note that Extract is not idempotent across retries: it issues a billed POST plus at least one follow-up GET, so retrying the whole call can start a second billed run. Webhook-driven consumers should use ExtractAsync — it performs the single POST and returns the accepted envelope as-is, so the run id is never lost to a failed follow-up request:

accepted, err := client.ExtractAsync(ctx, ws.Slug, "invoice",
	tracore.ExtractInput{DocumentID: docID}, nil)
if err != nil {
	// Status != 0: the API rejected the request, no run exists — safe to retry.
	// Status == 0 (ErrCodeTransport): outcome unknown — the connection may have
	// dropped after the server accepted; retry only if a duplicate run is acceptable.
}
store(accepted.RunId) // the run.completed webhook will quote this id

Error handling

Every call returns a *tracore.TracoreError on failure, carrying the HTTP status, the API error code, and any structured details.

ws, err := client.Workspaces.Get(ctx, "nonexistent")
if err != nil {
	if te, ok := tracore.AsTracoreError(err); ok {
		fmt.Println(te.Status)  // 404
		fmt.Println(te.Code)    // tracore.ErrCodeNotFound
		fmt.Println(te.Message) // "Workspace not found"
	}
}

Error codes are exported as constants — the client-side synthetic codes (tracore.ErrCodeTransport for network/decoding failures with Status == 0, tracore.ErrCodeConfig for invalid client-side input, tracore.ErrCodePollingTimeout for an exhausted poll loop) plus the server's error.code vocabulary (tracore.ErrCodeNotFound, tracore.ErrCodePlanLimitExceeded, ...). Transport failures keep their underlying cause reachable through errors.Is/errors.As (Unwrap), so checks like errors.Is(err, context.Canceled) or net.Error timeout detection work through the SDK wrapper.

Versioning

This SDK is generated from the Tracore OpenAPI contract. Its module version (vX.Y.Z, what go get resolves) follows SemVer; the API contract version it was built against is shown above and sent on every request as the Tracore-Version header. See CHANGELOG.md.

License

MIT — see LICENSE.

Documentation

Overview

Package tracore is the official Go SDK for the Tracore API — a schema-driven document-to-JSON extraction service.

client, err := tracore.New(tracore.ClientOptions{APIKey: os.Getenv("TRACORE_API_KEY")})
if err != nil { log.Fatal(err) }

run, err := client.Extract(ctx, "my-workspace", "invoice",
	tracore.ExtractInput{DocumentID: "doc-123"},
	&tracore.ExtractOptions{Poll: true})
if err != nil { log.Fatal(err) }
fmt.Println(run.Status, run.ExtractedData)

Index

Constants

View Source
const (
	// ErrCodeTransport marks a network, timeout, or encoding failure (retryable).
	ErrCodeTransport = "transport_error"
	// ErrCodeConfig marks invalid client-side input (permanent; a caller bug).
	ErrCodeConfig = "config_error"
	// ErrCodePollingTimeout marks a poll loop that exhausted MaxAttempts without
	// the run reaching a terminal status. The run is still live server-side.
	ErrCodePollingTimeout = "polling_timeout"
)

Synthetic client-side error codes. Set on TracoreError.Code for failures that never produced an HTTP response, so retry/breaker layers can classify without restating string literals.

View Source
const (
	ErrCodeNotFound            = "NOT_FOUND"
	ErrCodeValidation          = "VALIDATION_ERROR"
	ErrCodeUnauthorized        = "UNAUTHORIZED"
	ErrCodeInternal            = "INTERNAL_ERROR"
	ErrCodePlanLimitExceeded   = "plan_limit_exceeded"
	ErrCodeRateLimited         = "rate_limited"
	ErrCodeForbiddenKey        = "forbidden_key"
	ErrCodeInvalidProvider     = "invalid_provider"
	ErrCodeInvalidModel        = "invalid_model"
	ErrCodeNoKey               = "no_key"
	ErrCodeNotImplemented      = "not_implemented"
	ErrCodeEmailNotVerified    = "email_not_verified"
	ErrCodeStripeNotConfigured = "stripe_not_configured"
	ErrCodeNoStripeCustomer    = "no_stripe_customer"
	ErrCodeCheckoutMissingUser = "checkout_missing_user"
	ErrCodeInvalidSignature    = "invalid_signature"
)

Server-side `error.code` vocabulary, mirroring the contract's ApiErrorCode schema. The wire field stays a free-form string — new codes are not a breaking change — so match on these constants rather than an exhaustive switch. Note: key-validation failures arrive as ErrCodeValidation with `Details["code"] == "invalid_key"`, not as a top-level code. The last five constants surface only on internal billing surfaces and the Stripe webhook, never on public API endpoints.

View Source
const (
	RunStatusCompleted        = generated.RunStatusCompleted
	RunStatusFailed           = generated.RunStatusFailed
	RunStatusValidationFailed = generated.RunStatusValidationFailed
	RunStatusPending          = generated.RunStatusPending
	RunStatusProcessing       = generated.RunStatusProcessing
)

Run statuses. A run in Completed, Failed, or ValidationFailed is terminal.

View Source
const APIVersion = "0.6.0"

APIVersion is the Tracore API contract version this SDK was generated from — the `api-vX.Y.Z` release / .api-version, NOT this module's own Version. It is sent on every request as the `Tracore-Version` header and exposed as Client.APIVersion. Kept in sync with .api-version by sync.yml.

View Source
const DefaultBaseURL = "https://api.tracore.io"

DefaultBaseURL is the production Tracore API origin used when ClientOptions.BaseURL is empty.

View Source
const Version = "0.2.0"

Version is this SDK module's own semantic version. It is the version the publish workflow turns into the git tag vX.Y.Z (and thus the version `go get` resolves); it is independent of the API contract version below. sync.yml bumps it on regen.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiErrorCode added in v0.2.0

type ApiErrorCode = generated.ApiErrorCode

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type Client

type Client struct {

	// APIVersion is the API contract version this SDK was generated from, sent as
	// the Tracore-Version header. It is the API version, not this module's Version.
	APIVersion string

	// Workspaces manages workspaces.
	Workspaces *WorkspacesResource
	// Schemas manages schema families and versions.
	Schemas *SchemasResource
	// Documents manages documents (upload, download, delete).
	Documents *DocumentsResource
	// Runs lists, fetches, and polls extraction runs.
	Runs *RunsResource
	// Webhooks manages webhook endpoints and deliveries.
	Webhooks *WebhooksResource
	// Environments manages environments within a workspace.
	Environments *EnvironmentsResource
	// User exposes user-scoped resources for the authenticated user.
	User *UserResource
	// contains filtered or unexported fields
}

Client is the Tracore API client. Construct one with New and use its resource groups (Workspaces, Schemas, Documents, Runs, Webhooks, Environments, User) or the top-level Extract convenience.

func New

func New(opts ClientOptions) (*Client, error)

New constructs a Client. It returns an error only for invalid configuration; no network call is made here.

func (*Client) Extract

func (c *Client) Extract(ctx context.Context, workspace, schemaKey string, input ExtractInput, opts *ExtractOptions) (*Run, error)

Extract triggers an extraction run and, when ExtractOptions.Poll is set, waits for it to complete. It is a convenience over Documents.Upload + the schema extract endpoint + Runs.Poll.

Extract is NOT idempotent across retries: it issues a billed POST and then at least one follow-up GET, so retrying the whole call after a failure can start a second billed run even though the first one is live. Webhook-driven consumers that only need the run id should use ExtractAsync, which performs the single POST and returns the accepted envelope as-is.

func (*Client) ExtractAsync added in v0.2.0

func (c *Client) ExtractAsync(ctx context.Context, workspace, schemaKey string, input ExtractInput, opts *ExtractOptions) (*ExtractAcceptedResponse, error)

ExtractAsync triggers an extraction run and returns the API's 202 accepted envelope (run id + `pending` status) without any follow-up request. This is the fire-and-forget variant for webhook-driven consumers: the run id is never lost to a failed follow-up GET. Error semantics: a *TracoreError with Status != 0 means the API rejected the request and no run exists; a transport error (Status 0, ErrCodeTransport) is ambiguous — in the narrow window where the connection drops after the server responded, a billed run may already be live, so treat transport errors as "unknown outcome" (as with any HTTP client) and retry only if a duplicate run is acceptable. ExtractOptions.Poll and PollOptions are ignored.

type ClientOptions

type ClientOptions struct {
	// APIKey authenticates every request (sent as the x-api-key header). Required.
	APIKey string
	// BaseURL overrides the API origin. Defaults to DefaultBaseURL.
	BaseURL string
	// Environment is the default environment for environment-scoped requests.
	// Individual calls may override it. Empty defers to the server default.
	Environment Env
	// HTTPClient overrides the underlying *http.Client (timeouts, proxies, etc.).
	HTTPClient *http.Client
}

ClientOptions configures a Client.

type CreateDocumentRequest

type CreateDocumentRequest = generated.CreateDocumentRequest

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type CreateSchemaFamilyRequest

type CreateSchemaFamilyRequest = generated.CreateSchemaFamilyRequest

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type CreateWebhookRequest

type CreateWebhookRequest = generated.CreateWebhookRequest

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type CreateWorkspaceRequest

type CreateWorkspaceRequest = generated.CreateWorkspaceRequest

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type Document

type Document = generated.Document

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type DocumentExtractRequest

type DocumentExtractRequest = generated.DocumentExtractRequest

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type DocumentsResource

type DocumentsResource struct {
	// contains filtered or unexported fields
}

DocumentsResource manages documents. Documents are environment-scoped.

func (*DocumentsResource) Create

func (r *DocumentsResource) Create(ctx context.Context, workspace, schemaKey string, body CreateDocumentRequest, env Env) (*Document, error)

Create creates a document from text content. env is the target environment ("" uses the client default).

func (*DocumentsResource) Delete

func (r *DocumentsResource) Delete(ctx context.Context, id string) error

Delete deletes a document, its stored file, and all associated runs.

func (*DocumentsResource) Download

func (r *DocumentsResource) Download(ctx context.Context, id string) ([]byte, error)

Download returns the original document file bytes.

func (*DocumentsResource) Get

func (r *DocumentsResource) Get(ctx context.Context, id string) (*Document, error)

Get returns a document by ID.

func (*DocumentsResource) List

func (r *DocumentsResource) List(ctx context.Context, workspace, schemaKey string, params *ListParams) (*List[Document], error)

List returns the documents for a schema in an environment.

func (*DocumentsResource) Upload

func (r *DocumentsResource) Upload(ctx context.Context, workspace, schemaKey string, file io.Reader, name string, env Env) (*Document, error)

Upload uploads a file as a document. env is the target environment ("" uses the client default).

type Env

type Env string

Env names a Tracore environment for environment-scoped requests. The zero value ("") means "use the client default" (and, absent that, the server default of production).

const (
	EnvProduction  Env = "production"
	EnvStaging     Env = "staging"
	EnvDevelopment Env = "development"
)

type Environment

type Environment = generated.Environment

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type EnvironmentWithResolved

type EnvironmentWithResolved = generated.EnvironmentWithResolved

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type EnvironmentsResource

type EnvironmentsResource struct {
	// contains filtered or unexported fields
}

EnvironmentsResource manages the environments within a workspace. Each workspace has three: production (default) plus locked staging and development.

func (*EnvironmentsResource) Get

func (r *EnvironmentsResource) Get(ctx context.Context, workspace, envSlug string) (*EnvironmentWithResolved, error)

Get returns an environment by slug, including its resolved provider/model.

func (*EnvironmentsResource) List

func (r *EnvironmentsResource) List(ctx context.Context, workspace string, params *ListParams) (*List[Environment], error)

List returns the environments in a workspace.

func (*EnvironmentsResource) Update

Update updates an environment's provider/model assignment.

type ExtractAcceptedResponse added in v0.2.0

type ExtractAcceptedResponse = generated.ExtractAcceptedResponse

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type ExtractInput

type ExtractInput struct {
	// DocumentID extracts from an already-uploaded document.
	DocumentID string
	// File is the document content for an inline upload.
	File io.Reader
	// FileName is the display/file name for an inline upload.
	FileName string
}

ExtractInput selects what to extract from: either an existing document by ID (DocumentID) or an inline file upload (File + FileName). Provide exactly one.

type ExtractOptions

type ExtractOptions struct {
	// Env overrides the client's default environment.
	Env Env
	// VersionNumber pins a schema version. 0 uses the latest.
	VersionNumber int
	// Model is an optional `<provider>/<model>` override for this run.
	Model string
	// Poll, when true, blocks until the run reaches a terminal status.
	Poll bool
	// PollOptions tunes the poll loop (only used when Poll is true).
	PollOptions *PollOptions
}

ExtractOptions tunes an Extract call.

type List

type List[T any] struct {
	Data     []T `json:"data"`
	Page     int `json:"page"`
	PageSize int `json:"pageSize"`
	Total    int `json:"total"`
}

List is a paginated result set. It mirrors the API's PaginatedResponse envelope.

type ListParams

type ListParams struct {
	// Page is the 1-based page number. 0 means the server default.
	Page int
	// PageSize is the items per page (1-100). 0 means the server default.
	PageSize int
	// Env overrides the client's default environment for this call.
	Env Env
}

ListParams are the optional query parameters for paginated, environment-scoped list endpoints. A nil *ListParams (or zero fields) requests server defaults.

type PollOptions

type PollOptions struct {
	// Interval between poll requests. Default 1s.
	Interval time.Duration
	// MaxAttempts before giving up. Default 60.
	MaxAttempts int
	// OnProgress, if set, is called with the current run on each non-terminal poll.
	OnProgress func(*Run)
}

PollOptions configures Runs.Poll and the Extract auto-poll. The zero value polls every second for up to 60 attempts.

type ProviderKey

type ProviderKey = generated.ProviderKey

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type ProviderKeyListResponse

type ProviderKeyListResponse = generated.ProviderKeyListResponse

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type ProviderKeyPutRequest

type ProviderKeyPutRequest = generated.ProviderKeyPutRequest

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type ProviderKeyTestResponse

type ProviderKeyTestResponse = generated.ProviderKeyTestResponse

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type ProviderType

type ProviderType = generated.ProviderType

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type Run

type Run = generated.Run

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type RunListItem

type RunListItem = generated.RunListItem

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type RunStatus

type RunStatus = generated.RunStatus

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type RunsResource

type RunsResource struct {
	// contains filtered or unexported fields
}

RunsResource lists, fetches, and polls extraction runs. Runs are environment-scoped.

func (*RunsResource) Get

func (r *RunsResource) Get(ctx context.Context, id string) (*Run, error)

Get returns a run by ID.

func (*RunsResource) List

func (r *RunsResource) List(ctx context.Context, workspace, schemaKey string, params *ListParams) (*List[RunListItem], error)

List returns the runs for a schema in an environment.

func (*RunsResource) Poll

func (r *RunsResource) Poll(ctx context.Context, id string, opts *PollOptions) (*Run, error)

Poll blocks until a run reaches a terminal status (completed, failed, or validation_failed), ctx is cancelled, or the attempt budget is exhausted.

type SchemaFamily

type SchemaFamily = generated.SchemaFamily

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type SchemaFamilyWithVersion

type SchemaFamilyWithVersion = generated.SchemaFamilyWithVersion

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type SchemaVersion

type SchemaVersion = generated.SchemaVersion

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type SchemasResource

type SchemasResource struct {
	// contains filtered or unexported fields
}

SchemasResource manages schema families and their immutable versions. Schemas are workspace-scoped (shared across environments).

func (*SchemasResource) Create

Create creates a schema family and its first version. Returns the family with the resolved version.

func (*SchemasResource) Get

func (r *SchemasResource) Get(ctx context.Context, workspace, schemaKey string) (*SchemaFamily, error)

Get returns a schema family by key.

func (*SchemasResource) GetVersion

func (r *SchemasResource) GetVersion(ctx context.Context, workspace, schemaKey string, versionNumber int) (*SchemaVersion, error)

GetVersion returns a specific schema version by number.

func (*SchemasResource) List

func (r *SchemasResource) List(ctx context.Context, workspace string, params *ListParams) (*List[SchemaFamily], error)

List returns the schema families in a workspace.

func (*SchemasResource) ListVersions

func (r *SchemasResource) ListVersions(ctx context.Context, workspace, schemaKey string, params *ListParams) (*List[SchemaVersion], error)

ListVersions returns the versions of a schema family.

type SendTestWebhookRequest

type SendTestWebhookRequest = generated.SendTestWebhookRequest

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type TracoreError

type TracoreError struct {
	// Status is the HTTP status code, or 0 for a client-side failure.
	Status int
	// Code is the machine-readable error code from the API, when provided.
	Code string
	// Message is the human-readable error message.
	Message string
	// Details carries additional structured error context, when provided.
	Details map[string]interface{}
	// contains filtered or unexported fields
}

TracoreError is returned by every SDK call that fails. For HTTP failures Status is the response status code and Code/Message/Details come from the API's `{ "error": { code, message, details } }` envelope. For client-side failures (transport, encoding) Status is 0 and Code is ErrCodeTransport.

func AsTracoreError

func AsTracoreError(err error) (*TracoreError, bool)

AsTracoreError unwraps err into a *TracoreError if it is one. It is a thin convenience over errors.As for the common call-site check.

if te, ok := tracore.AsTracoreError(err); ok && te.Status == 404 { ... }

func (*TracoreError) Error

func (e *TracoreError) Error() string

func (*TracoreError) Unwrap added in v0.2.0

func (e *TracoreError) Unwrap() error

Unwrap returns the underlying cause (nil for pure HTTP envelope errors), making the wrapper transparent to errors.Is and errors.As.

type UpdateEnvironmentRequest

type UpdateEnvironmentRequest = generated.UpdateEnvironmentRequest

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type UpdateWebhookRequest

type UpdateWebhookRequest = generated.UpdateWebhookRequest

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type UpdateWorkspaceRequest

type UpdateWorkspaceRequest = generated.UpdateWorkspaceRequest

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type UserPlanResponse

type UserPlanResponse = generated.UserPlanResponse

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type UserProviderKeysResource

type UserProviderKeysResource struct {
	// contains filtered or unexported fields
}

UserProviderKeysResource manages the current user's AI provider keys (BYOK). Keys are user-scoped (one per provider, reused across the user's workspaces). These endpoints require session-cookie auth; API-key auth is rejected by design.

func (*UserProviderKeysResource) Get

Get returns a single provider key's metadata.

func (*UserProviderKeysResource) List

List returns the user's provider keys (masked previews, never plaintext).

func (*UserProviderKeysResource) Remove

func (r *UserProviderKeysResource) Remove(ctx context.Context, provider ProviderType) error

Remove deletes the user's key for a provider, reverting any environment that referenced it to the system Mistral fallback.

func (*UserProviderKeysResource) Set

Set creates, replaces, or updates the user's key for a provider. Supply ProviderKeyPutRequest.Key to test-and-store a key, or only DefaultModel to change the profile default model without re-encrypting.

func (*UserProviderKeysResource) Test

Test re-tests the stored provider key against the provider and returns the new status.

type UserResource

type UserResource struct {

	// ProviderKeys manages the user's AI provider keys (BYOK).
	ProviderKeys *UserProviderKeysResource
	// contains filtered or unexported fields
}

UserResource groups user-scoped resources for the authenticated user.

func (*UserResource) Plan

Plan returns the authenticated user's plan and current usage counters.

type WebhookDelivery

type WebhookDelivery = generated.WebhookDelivery

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type WebhookEndpoint

type WebhookEndpoint = generated.WebhookEndpoint

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type WebhookEventType added in v0.2.0

type WebhookEventType = generated.WebhookEventType

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type WebhookPayload added in v0.2.0

type WebhookPayload = generated.WebhookPayload

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type WebhooksResource

type WebhooksResource struct {
	// contains filtered or unexported fields
}

WebhooksResource manages webhook endpoints and their deliveries. Endpoints are scoped to a schema and environment; delivery dispatch is environment-wide.

func (*WebhooksResource) Create

func (r *WebhooksResource) Create(ctx context.Context, workspace, schemaKey string, body CreateWebhookRequest, env Env) (*WebhookEndpoint, error)

Create creates a webhook endpoint for a schema in an environment. env is the target environment ("" uses the client default).

func (*WebhooksResource) Delete

func (r *WebhooksResource) Delete(ctx context.Context, id string) error

Delete deletes a webhook endpoint.

func (*WebhooksResource) Get

Get returns a webhook endpoint by ID.

func (*WebhooksResource) List

func (r *WebhooksResource) List(ctx context.Context, workspace, schemaKey string, params *ListParams) (*List[WebhookEndpoint], error)

List returns the webhook endpoints for a schema in an environment.

func (*WebhooksResource) ListDeliveries

func (r *WebhooksResource) ListDeliveries(ctx context.Context, id string, params *ListParams) (*List[WebhookDelivery], error)

ListDeliveries returns the delivery attempts for a webhook endpoint.

func (*WebhooksResource) SendTest

func (r *WebhooksResource) SendTest(ctx context.Context, id string, body SendTestWebhookRequest) (bool, error)

SendTest dispatches a synthetic test event to a webhook endpoint. It reports whether the event was sent.

func (*WebhooksResource) Update

Update updates a webhook endpoint.

type Workspace

type Workspace = generated.Workspace

Re-exported model types. Callers use these instead of the internal generated package (which is import-restricted to this module). They are type aliases, so they are identical to the generated types — no conversion is needed.

type WorkspacesResource

type WorkspacesResource struct {
	// contains filtered or unexported fields
}

WorkspacesResource manages workspaces.

func (*WorkspacesResource) Create

Create creates a workspace.

func (*WorkspacesResource) Delete

func (r *WorkspacesResource) Delete(ctx context.Context, slug string) error

Delete deletes a workspace and all of its schemas, documents, and runs.

func (*WorkspacesResource) Get

func (r *WorkspacesResource) Get(ctx context.Context, slug string) (*Workspace, error)

Get returns a workspace by slug.

func (*WorkspacesResource) List

func (r *WorkspacesResource) List(ctx context.Context, params *ListParams) (*List[Workspace], error)

List returns the caller's workspaces.

func (*WorkspacesResource) Update

Update updates a workspace.

Directories

Path Synopsis
cmd
downconvert command
Command downconvert performs a minimal OpenAPI 3.1 -> 3.0 rewrite so oapi-codegen (which does not yet support 3.1, see oapi-codegen/oapi-codegen#373) can consume the Tracore spec.
Command downconvert performs a minimal OpenAPI 3.1 -> 3.0 rewrite so oapi-codegen (which does not yet support 3.1, see oapi-codegen/oapi-codegen#373) can consume the Tracore spec.
Command examples demonstrates the Tracore Go SDK end to end.
Command examples demonstrates the Tracore Go SDK end to end.
internal
generated
Package generated provides primitives to interact with the openapi HTTP API.
Package generated provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL