Documentation
¶
Index ¶
- func Bool(b bool) param.Opt[bool]
- func BoolPtr(v bool) *bool
- func DefaultClientOptions() []option.RequestOption
- func File(rdr io.Reader, filename string, contentType string) file
- func Float(f float64) param.Opt[float64]
- func FloatPtr(v float64) *float64
- func Int(i int64) param.Opt[int64]
- func IntPtr(v int64) *int64
- func Opt[T comparable](v T) param.Opt[T]
- func Ptr[T any](v T) *T
- func String(s string) param.Opt[string]
- func StringPtr(v string) *string
- func Time(t time.Time) param.Opt[time.Time]
- func TimePtr(v time.Time) *time.Time
- type Client
- func (r *Client) Delete(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, ...) error
- func (r *Client) Get(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Patch(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Post(ctx context.Context, path string, params any, res any, ...) error
- func (r *Client) Put(ctx context.Context, path string, params any, res any, ...) error
- type Error
- type FileService
- type HealthCheckResponse
- type HealthService
- type WebhookListResponse
- type WebhookNewParams
- type WebhookNewResponse
- type WebhookService
- func (r *WebhookService) Delete(ctx context.Context, webhookID string, opts ...option.RequestOption) (err error)
- func (r *WebhookService) List(ctx context.Context, opts ...option.RequestOption) (res *[]WebhookListResponse, err error)
- func (r *WebhookService) New(ctx context.Context, body WebhookNewParams, opts ...option.RequestOption) (res *WebhookNewResponse, err error)
- type Workflow
- type WorkflowGetFileResultsParams
- type WorkflowGetFileResultsResponse
- type WorkflowListFilesParams
- type WorkflowListFilesResponse
- type WorkflowListFilesResponseResult
- type WorkflowListParams
- type WorkflowListResponse
- type WorkflowListRunsParams
- type WorkflowListRunsResponse
- type WorkflowListRunsResponseResult
- type WorkflowNewFileParams
- type WorkflowNewFileResponse
- type WorkflowNewFileResponseFile
- type WorkflowRunParams
- type WorkflowRunResponse
- type WorkflowService
- func (r *WorkflowService) Delete(ctx context.Context, workflowID string, opts ...option.RequestOption) (err error)
- func (r *WorkflowService) Get(ctx context.Context, workflowID string, opts ...option.RequestOption) (res *Workflow, err error)
- func (r *WorkflowService) GetFileResults(ctx context.Context, collectionID string, query WorkflowGetFileResultsParams, ...) (res *WorkflowGetFileResultsResponse, err error)
- func (r *WorkflowService) List(ctx context.Context, query WorkflowListParams, opts ...option.RequestOption) (res *WorkflowListResponse, err error)
- func (r *WorkflowService) ListFiles(ctx context.Context, workflowID string, query WorkflowListFilesParams, ...) (res *WorkflowListFilesResponse, err error)
- func (r *WorkflowService) ListRuns(ctx context.Context, workflowID string, query WorkflowListRunsParams, ...) (res *WorkflowListRunsResponse, err error)
- func (r *WorkflowService) New(ctx context.Context, opts ...option.RequestOption) (res *Workflow, err error)
- func (r *WorkflowService) NewFile(ctx context.Context, workflowID string, body WorkflowNewFileParams, ...) (res *WorkflowNewFileResponse, err error)
- func (r *WorkflowService) Run(ctx context.Context, workflowID string, body WorkflowRunParams, ...) (res *WorkflowRunResponse, err error)
- func (r *WorkflowService) Upload(ctx context.Context, workflowID string, body WorkflowUploadParams, ...) (res *WorkflowUploadResponse, err error)
- type WorkflowUploadParams
- type WorkflowUploadResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultClientOptions ¶
func DefaultClientOptions() []option.RequestOption
DefaultClientOptions read from the environment (ANYFORMAT_API_KEY, ANYFORMAT_BASE_URL). This should be used to initialize new clients.
func Opt ¶
func Opt[T comparable](v T) param.Opt[T]
Types ¶
type Client ¶
type Client struct {
// Health check endpoints to verify API availability.
Health HealthService
// Webhook subscriptions for asynchronous event notifications. Get notified when
// extractions complete or fail.
Webhooks WebhookService
// File collections group uploaded documents and track their extraction progress.
// Upload files, check status, and retrieve extraction results.
Files FileService
Workflows WorkflowService
// contains filtered or unexported fields
}
Client creates a struct with services and top level methods that help with interacting with the anyformat API. You should not instantiate this client directly, and instead use the NewClient method instead.
func NewClient ¶
func NewClient(opts ...option.RequestOption) (r Client)
NewClient generates a new client with the default option read from the environment (ANYFORMAT_API_KEY, ANYFORMAT_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.
func (*Client) Delete ¶
func (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Execute ¶
func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error
Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.
If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.
The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.
If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.
Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.
The response body will be deserialized into the res variable, depending on its type:
- A pointer to a *http.Response is populated by the raw response.
- A pointer to a byte array will be populated with the contents of the request body.
- A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
- A nil value will not read the response body.
For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.
func (*Client) Get ¶
func (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
func (*Client) Patch ¶
func (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error
Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.
type FileService ¶
type FileService struct {
// contains filtered or unexported fields
}
File collections group uploaded documents and track their extraction progress. Upload files, check status, and retrieve extraction results.
FileService contains methods and other services that help with interacting with the anyformat API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewFileService method instead.
func NewFileService ¶
func NewFileService(opts ...option.RequestOption) (r FileService)
NewFileService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*FileService) Delete ¶
func (r *FileService) Delete(ctx context.Context, collectionID string, opts ...option.RequestOption) (err error)
Delete a file collection and all its files permanently.
This removes all uploaded files and any extraction results associated with the collection. This action is irreversible.
type HealthCheckResponse ¶
type HealthCheckResponse struct {
// Status message. Returns `"ok"` when the service is healthy.
Message string `json:"message" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Message respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Health check response confirming the API is operational.
func (HealthCheckResponse) RawJSON ¶ added in v0.3.0
func (r HealthCheckResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*HealthCheckResponse) UnmarshalJSON ¶ added in v0.3.0
func (r *HealthCheckResponse) UnmarshalJSON(data []byte) error
type HealthService ¶
type HealthService struct {
// contains filtered or unexported fields
}
Health check endpoints to verify API availability.
HealthService contains methods and other services that help with interacting with the anyformat API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewHealthService method instead.
func NewHealthService ¶
func NewHealthService(opts ...option.RequestOption) (r HealthService)
NewHealthService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*HealthService) Check ¶
func (r *HealthService) Check(ctx context.Context, opts ...option.RequestOption) (res *HealthCheckResponse, err error)
Returns 200 OK if the service is running. No authentication required.
Use this endpoint to verify API connectivity before making authenticated calls.
type WebhookListResponse ¶
type WebhookListResponse struct {
// Unique identifier of the webhook.
ID string `json:"id" api:"required"`
// Timestamp when the webhook was created (ISO 8601).
CreatedAt string `json:"created_at" api:"required"`
// Event types this webhook is subscribed to.
Events []string `json:"events" api:"required"`
// Whether the webhook is currently active.
IsActive bool `json:"is_active" api:"required"`
// The URL receiving webhook events.
URL string `json:"url" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
CreatedAt respjson.Field
Events respjson.Field
IsActive respjson.Field
URL respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Webhook subscription details (secret excluded for security).
func (WebhookListResponse) RawJSON ¶
func (r WebhookListResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*WebhookListResponse) UnmarshalJSON ¶
func (r *WebhookListResponse) UnmarshalJSON(data []byte) error
type WebhookNewParams ¶
type WebhookNewParams struct {
// The HTTPS URL to receive webhook events. Must be publicly accessible.
URL string `json:"url" api:"required" format:"uri"`
// List of event types to subscribe to. Available events: `extraction.completed`,
// `extraction.failed`.
Events []string `json:"events,omitzero"`
// contains filtered or unexported fields
}
func (WebhookNewParams) MarshalJSON ¶
func (r WebhookNewParams) MarshalJSON() (data []byte, err error)
func (*WebhookNewParams) UnmarshalJSON ¶
func (r *WebhookNewParams) UnmarshalJSON(data []byte) error
type WebhookNewResponse ¶
type WebhookNewResponse struct {
// Unique identifier of the webhook.
ID string `json:"id" api:"required"`
// Timestamp when the webhook was created (ISO 8601).
CreatedAt string `json:"created_at" api:"required"`
// Event types this webhook is subscribed to.
Events []string `json:"events" api:"required"`
// Whether the webhook is currently active and receiving events.
IsActive bool `json:"is_active" api:"required"`
// Webhook signing secret. Use this to verify that incoming webhook requests are
// authentic. **Store securely — this value is only shown once at creation time.**
Secret string `json:"secret" api:"required"`
// The URL receiving webhook events.
URL string `json:"url" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
CreatedAt respjson.Field
Events respjson.Field
IsActive respjson.Field
Secret respjson.Field
URL respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Webhook subscription details including the signing secret. The secret is only returned at creation time.
func (WebhookNewResponse) RawJSON ¶
func (r WebhookNewResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*WebhookNewResponse) UnmarshalJSON ¶
func (r *WebhookNewResponse) UnmarshalJSON(data []byte) error
type WebhookService ¶
type WebhookService struct {
// contains filtered or unexported fields
}
Webhook subscriptions for asynchronous event notifications. Get notified when extractions complete or fail.
WebhookService contains methods and other services that help with interacting with the anyformat API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewWebhookService method instead.
func NewWebhookService ¶
func NewWebhookService(opts ...option.RequestOption) (r WebhookService)
NewWebhookService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*WebhookService) Delete ¶
func (r *WebhookService) Delete(ctx context.Context, webhookID string, opts ...option.RequestOption) (err error)
Delete a webhook subscription by ID.
After deletion, AnyFormat will stop sending events to the webhook URL. This action is irreversible.
func (*WebhookService) List ¶
func (r *WebhookService) List(ctx context.Context, opts ...option.RequestOption) (res *[]WebhookListResponse, err error)
List all webhook subscriptions for the authenticated organization.
Returns a list of webhooks. Secrets are excluded from the list response for security — they are only returned once, when the webhook is created.
func (*WebhookService) New ¶
func (r *WebhookService) New(ctx context.Context, body WebhookNewParams, opts ...option.RequestOption) (res *WebhookNewResponse, err error)
Create a new webhook subscription for your organization.
The webhook URL must use HTTPS. AnyFormat will send POST requests to this URL when the subscribed events occur. The response includes a `secret` that you should use to verify webhook signatures.
Supported events:
- `extraction.completed` — fired when a file extraction finishes successfully. - `extraction.failed` — fired when a file extraction fails.
type Workflow ¶
type Workflow struct {
// Unique identifier of the workflow (UUID).
ID string `json:"id" api:"required"`
// Human-readable name of the workflow.
Name string `json:"name" api:"required"`
// Timestamp when the workflow was created (ISO 8601).
CreatedAt time.Time `json:"created_at" api:"nullable" format:"date-time"`
// Optional description of what this workflow extracts.
Description string `json:"description" api:"nullable"`
// List of extraction field definitions configured for this workflow. `null` if not
// yet configured.
Fields []map[string]any `json:"fields" api:"nullable"`
// Timestamp when the workflow was last modified (ISO 8601).
UpdatedAt time.Time `json:"updated_at" api:"nullable" format:"date-time"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Name respjson.Field
CreatedAt respjson.Field
Description respjson.Field
Fields respjson.Field
UpdatedAt respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
A workflow defines the extraction template — what fields to extract from documents, their types, and validation rules.
func (*Workflow) UnmarshalJSON ¶
type WorkflowGetFileResultsParams ¶ added in v0.2.0
type WorkflowGetFileResultsParams struct {
WorkflowID string `path:"workflow_id" api:"required" json:"-"`
// contains filtered or unexported fields
}
type WorkflowGetFileResultsResponse ¶ added in v0.2.0
type WorkflowGetFileResultsResponse = any
type WorkflowListFilesParams ¶ added in v0.2.0
type WorkflowListFilesParams struct {
Page param.Opt[int64] `query:"page,omitzero" json:"-"`
PageSize param.Opt[int64] `query:"page_size,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (WorkflowListFilesParams) URLQuery ¶ added in v0.2.0
func (r WorkflowListFilesParams) URLQuery() (v url.Values, err error)
URLQuery serializes WorkflowListFilesParams's query parameters as `url.Values`.
type WorkflowListFilesResponse ¶ added in v0.2.0
type WorkflowListFilesResponse struct {
// Total number of items matching the query.
Count int64 `json:"count" api:"required"`
// Current page number.
Page int64 `json:"page" api:"required"`
// Number of results per page.
PageSize int64 `json:"page_size" api:"required"`
// List of items for the current page.
Results []WorkflowListFilesResponseResult `json:"results" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Count respjson.Field
Page respjson.Field
PageSize respjson.Field
Results respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
func (WorkflowListFilesResponse) RawJSON ¶ added in v0.2.0
func (r WorkflowListFilesResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*WorkflowListFilesResponse) UnmarshalJSON ¶ added in v0.2.0
func (r *WorkflowListFilesResponse) UnmarshalJSON(data []byte) error
type WorkflowListFilesResponseResult ¶ added in v0.2.0
type WorkflowListFilesResponseResult struct {
// Unique identifier of the file collection.
ID string `json:"id" api:"required"`
// Processing status: `pending`, `processing`, `completed`, or `failed`.
Status string `json:"status" api:"required"`
// Timestamp when the collection was created (ISO 8601).
CreatedAt time.Time `json:"created_at" api:"nullable" format:"date-time"`
// Human-readable name for the collection.
Name string `json:"name" api:"nullable"`
// Timestamp when the collection was last updated (ISO 8601).
UpdatedAt time.Time `json:"updated_at" api:"nullable" format:"date-time"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Status respjson.Field
CreatedAt respjson.Field
Name respjson.Field
UpdatedAt respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
A file collection entry in list responses. Each collection groups one or more uploaded files and tracks their extraction status.
func (WorkflowListFilesResponseResult) RawJSON ¶ added in v0.2.0
func (r WorkflowListFilesResponseResult) RawJSON() string
Returns the unmodified JSON received from the API
func (*WorkflowListFilesResponseResult) UnmarshalJSON ¶ added in v0.2.0
func (r *WorkflowListFilesResponseResult) UnmarshalJSON(data []byte) error
type WorkflowListParams ¶
type WorkflowListParams struct {
Order param.Opt[string] `query:"order,omitzero" json:"-"`
SortBy param.Opt[string] `query:"sort_by,omitzero" json:"-"`
Status param.Opt[string] `query:"status,omitzero" json:"-"`
Page param.Opt[int64] `query:"page,omitzero" json:"-"`
PageSize param.Opt[int64] `query:"page_size,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (WorkflowListParams) URLQuery ¶
func (r WorkflowListParams) URLQuery() (v url.Values, err error)
URLQuery serializes WorkflowListParams's query parameters as `url.Values`.
type WorkflowListResponse ¶
type WorkflowListResponse struct {
// Total number of workflows matching the query.
Count int64 `json:"count" api:"required"`
// Current page number.
Page int64 `json:"page" api:"required"`
// Number of results per page.
PageSize int64 `json:"page_size" api:"required"`
// List of workflows for the current page.
Results []Workflow `json:"results" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Count respjson.Field
Page respjson.Field
PageSize respjson.Field
Results respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Paginated list of workflows.
func (WorkflowListResponse) RawJSON ¶
func (r WorkflowListResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*WorkflowListResponse) UnmarshalJSON ¶
func (r *WorkflowListResponse) UnmarshalJSON(data []byte) error
type WorkflowListRunsParams ¶
type WorkflowListRunsParams struct {
Page param.Opt[int64] `query:"page,omitzero" json:"-"`
PageSize param.Opt[int64] `query:"page_size,omitzero" json:"-"`
// contains filtered or unexported fields
}
func (WorkflowListRunsParams) URLQuery ¶
func (r WorkflowListRunsParams) URLQuery() (v url.Values, err error)
URLQuery serializes WorkflowListRunsParams's query parameters as `url.Values`.
type WorkflowListRunsResponse ¶
type WorkflowListRunsResponse struct {
// Total number of runs for this workflow.
Count int64 `json:"count" api:"required"`
// Current page number.
Page int64 `json:"page" api:"required"`
// Number of results per page.
PageSize int64 `json:"page_size" api:"required"`
// List of runs for the current page.
Results []WorkflowListRunsResponseResult `json:"results" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Count respjson.Field
Page respjson.Field
PageSize respjson.Field
Results respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Paginated list of workflow runs.
func (WorkflowListRunsResponse) RawJSON ¶
func (r WorkflowListRunsResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*WorkflowListRunsResponse) UnmarshalJSON ¶
func (r *WorkflowListRunsResponse) UnmarshalJSON(data []byte) error
type WorkflowListRunsResponseResult ¶
type WorkflowListRunsResponseResult struct {
// The collection UUID for this run. Use this ID with
// `GET /v2/workflows/{workflow_id}/files/{id}/results/` to fetch results.
ID string `json:"id" api:"required"`
// Processing status: `pending`, `processing`, `completed`, or `failed`.
Status string `json:"status" api:"required"`
// Timestamp when the run started (ISO 8601).
CreatedAt time.Time `json:"created_at" api:"nullable" format:"date-time"`
// Timestamp when the run status was last updated (ISO 8601).
UpdatedAt time.Time `json:"updated_at" api:"nullable" format:"date-time"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Status respjson.Field
CreatedAt respjson.Field
UpdatedAt respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
An extraction run entry, representing one execution of a workflow on a file collection.
func (WorkflowListRunsResponseResult) RawJSON ¶
func (r WorkflowListRunsResponseResult) RawJSON() string
Returns the unmodified JSON received from the API
func (*WorkflowListRunsResponseResult) UnmarshalJSON ¶
func (r *WorkflowListRunsResponseResult) UnmarshalJSON(data []byte) error
type WorkflowNewFileParams ¶ added in v0.2.0
type WorkflowNewFileParams struct {
Files []string `json:"files,omitzero" api:"required"`
// contains filtered or unexported fields
}
func (WorkflowNewFileParams) MarshalMultipart ¶ added in v0.2.0
func (r WorkflowNewFileParams) MarshalMultipart() (data []byte, contentType string, err error)
type WorkflowNewFileResponse ¶ added in v0.2.0
type WorkflowNewFileResponse struct {
// Unique identifier of the newly created file collection.
ID string `json:"id" api:"required"`
// List of files included in the collection, with their upload status.
Files []WorkflowNewFileResponseFile `json:"files" api:"required"`
// The UUID of the workflow this collection belongs to.
WorkflowID string `json:"workflow_id" api:"required"`
// Human-readable name for the collection.
Name string `json:"name" api:"nullable"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Files respjson.Field
WorkflowID respjson.Field
Name respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Response from creating a file collection. Contains the collection ID and the status of each uploaded file.
func (WorkflowNewFileResponse) RawJSON ¶ added in v0.2.0
func (r WorkflowNewFileResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*WorkflowNewFileResponse) UnmarshalJSON ¶ added in v0.2.0
func (r *WorkflowNewFileResponse) UnmarshalJSON(data []byte) error
type WorkflowNewFileResponseFile ¶ added in v0.2.0
type WorkflowNewFileResponseFile struct {
// Name of the uploaded file.
Filename string `json:"filename" api:"required"`
// Upload status: `uploaded` or `failed`.
Status string `json:"status" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Filename respjson.Field
Status respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
A single file within a collection, showing its name and upload status.
func (WorkflowNewFileResponseFile) RawJSON ¶ added in v0.2.0
func (r WorkflowNewFileResponseFile) RawJSON() string
Returns the unmodified JSON received from the API
func (*WorkflowNewFileResponseFile) UnmarshalJSON ¶ added in v0.2.0
func (r *WorkflowNewFileResponseFile) UnmarshalJSON(data []byte) error
type WorkflowRunParams ¶
type WorkflowRunParams struct {
File param.Opt[string] `json:"file,omitzero"`
Text param.Opt[string] `json:"text,omitzero"`
// contains filtered or unexported fields
}
func (WorkflowRunParams) MarshalMultipart ¶
func (r WorkflowRunParams) MarshalMultipart() (data []byte, contentType string, err error)
type WorkflowRunResponse ¶
type WorkflowRunResponse struct {
// The collection UUID for this run. Use this ID to poll for results via
// `GET /v2/workflows/{workflow_id}/files/{id}/results/`.
ID string `json:"id" api:"required"`
// Initial status of the run, typically `success` (meaning the run was accepted,
// not that extraction is complete).
Status string `json:"status" api:"required"`
// The UUID of the workflow that was executed.
WorkflowID string `json:"workflow_id" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
Status respjson.Field
WorkflowID respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Response after triggering a workflow run. Contains the collection ID to use for polling extraction results.
func (WorkflowRunResponse) RawJSON ¶
func (r WorkflowRunResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*WorkflowRunResponse) UnmarshalJSON ¶
func (r *WorkflowRunResponse) UnmarshalJSON(data []byte) error
type WorkflowService ¶
type WorkflowService struct {
// contains filtered or unexported fields
}
WorkflowService contains methods and other services that help with interacting with the anyformat API.
Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewWorkflowService method instead.
func NewWorkflowService ¶
func NewWorkflowService(opts ...option.RequestOption) (r WorkflowService)
NewWorkflowService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.
func (*WorkflowService) Delete ¶
func (r *WorkflowService) Delete(ctx context.Context, workflowID string, opts ...option.RequestOption) (err error)
Delete a workflow and all associated file collections and extraction results.
This action is irreversible.
func (*WorkflowService) Get ¶
func (r *WorkflowService) Get(ctx context.Context, workflowID string, opts ...option.RequestOption) (res *Workflow, err error)
Retrieve a single workflow by its ID, including its configured extraction fields.
func (*WorkflowService) GetFileResults ¶ added in v0.2.0
func (r *WorkflowService) GetFileResults(ctx context.Context, collectionID string, query WorkflowGetFileResultsParams, opts ...option.RequestOption) (res *WorkflowGetFileResultsResponse, err error)
Retrieve the extraction results for a file collection.
Returns the structured data extracted from each file, including field values, confidence scores, and source evidence (text excerpts and page numbers). Also includes a `verification_url` linking to the AnyFormat dashboard for human review.
Returns **412 Precondition Failed** if the extraction is still in progress. Poll this endpoint until you receive a 200 response, or use webhooks (`extraction.completed` event) to be notified when processing finishes.
func (*WorkflowService) List ¶
func (r *WorkflowService) List(ctx context.Context, query WorkflowListParams, opts ...option.RequestOption) (res *WorkflowListResponse, err error)
List all workflows in your organization with pagination.
Workflows can be filtered by status and sorted by any field.
func (*WorkflowService) ListFiles ¶ added in v0.2.0
func (r *WorkflowService) ListFiles(ctx context.Context, workflowID string, query WorkflowListFilesParams, opts ...option.RequestOption) (res *WorkflowListFilesResponse, err error)
List file collections for a workflow.
A file collection groups one or more uploaded files together. Each collection has a status indicating the extraction progress: `pending`, `processing`, `completed`, or `failed`.
func (*WorkflowService) ListRuns ¶
func (r *WorkflowService) ListRuns(ctx context.Context, workflowID string, query WorkflowListRunsParams, opts ...option.RequestOption) (res *WorkflowListRunsResponse, err error)
List all extraction runs for a workflow with pagination.
Each run corresponds to a file collection that was processed by the workflow. Use the run's `id` (collection UUID) with `GET /v2/workflows/{workflow_id}/files/{id}/results/` to fetch detailed results.
func (*WorkflowService) New ¶
func (r *WorkflowService) New(ctx context.Context, opts ...option.RequestOption) (res *Workflow, err error)
Create a new extraction workflow.
Workflows define what data to extract from documents. After creating a workflow, configure its extraction fields in the [AnyFormat dashboard](https://app.anyformat.ai).
func (*WorkflowService) NewFile ¶ added in v0.2.0
func (r *WorkflowService) NewFile(ctx context.Context, workflowID string, body WorkflowNewFileParams, opts ...option.RequestOption) (res *WorkflowNewFileResponse, err error)
Upload one or more files to a workflow, creating a new file collection.
Use this when you want to upload files without immediately running extraction. To upload and extract in one step, use `POST /v2/workflows/{workflow_id}/run/` instead.
Supported file types: PDF, PNG, JPG, TIFF, TXT, DOCX, XLSX, CSV, and more.
func (*WorkflowService) Run ¶
func (r *WorkflowService) Run(ctx context.Context, workflowID string, body WorkflowRunParams, opts ...option.RequestOption) (res *WorkflowRunResponse, err error)
Upload a file and immediately run the extraction workflow on it.
This is the primary endpoint for document extraction. It creates a file collection, uploads the file, and starts extraction in one step. The response includes a collection `id` that you can use to poll for results via `GET /v2/workflows/{workflow_id}/files/{collection_id}/results/`.
Provide the file as a binary upload in the `file` field, or send raw text in the `text` field for text-only extraction.
func (*WorkflowService) Upload ¶
func (r *WorkflowService) Upload(ctx context.Context, workflowID string, body WorkflowUploadParams, opts ...option.RequestOption) (res *WorkflowUploadResponse, err error)
Upload a file to a workflow without running extraction.
Use this when you want to stage files for later processing. For upload-and-extract in one step, use `POST /v2/workflows/{workflow_id}/run/` instead.
type WorkflowUploadParams ¶
type WorkflowUploadParams struct {
File param.Opt[string] `json:"file,omitzero"`
Text param.Opt[string] `json:"text,omitzero"`
// contains filtered or unexported fields
}
func (WorkflowUploadParams) MarshalMultipart ¶
func (r WorkflowUploadParams) MarshalMultipart() (data []byte, contentType string, err error)
type WorkflowUploadResponse ¶
type WorkflowUploadResponse struct {
// Upload result: `uploaded` on success.
Status string `json:"status" api:"required"`
// Name of the uploaded file.
Filename string `json:"filename" api:"nullable"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Status respjson.Field
Filename respjson.Field
ExtraFields map[string]respjson.Field
// contains filtered or unexported fields
} `json:"-"`
}
Confirmation that a file was uploaded successfully without triggering extraction.
func (WorkflowUploadResponse) RawJSON ¶
func (r WorkflowUploadResponse) RawJSON() string
Returns the unmodified JSON received from the API
func (*WorkflowUploadResponse) UnmarshalJSON ¶
func (r *WorkflowUploadResponse) UnmarshalJSON(data []byte) error
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
|
Package json implements encoding and decoding of JSON as defined in RFC 7159. |
|
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
|
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package. |
|
packages
|
|
|
shared
|
|