Documents.Get
func (d *Documents) Get(ctx context.Context, id string, opts ...option.RequestOption) (*DocumentDescriptor, error)Get retrieves a stored document’s descriptor with a fresh presigned URL. The returned descriptor’s DocumentDescriptor.DownloadPDF uses the parent client for transport; calling it after the URL’s ~15-minute TTL returns *Error{Code: ErrCodeDownloadFailed} — re-fetch via Get.
Spec §6.1.
Parameters
Section titled “Parameters”| Name | Type | Required | Description |
|---|---|---|---|
ctx | context.Context | required | (no description) |
id | string | required | (no description) |
opts | ...option.RequestOption | — | (no description) |
Returns
Section titled “Returns”*DocumentDescriptor, error
Errors
Section titled “Errors”| Code | When |
|---|---|
DOCUMENT_NOT_FOUND | No stored document matches the supplied id. |
DOCUMENT_GONE | The document was deleted or has expired. |
INVALID_API_KEY | The API key is malformed or revoked. |
INTERNAL_ERROR | API returned 5xx. Retryable. |
Example
Section titled “Example”// Demonstrates: client.Documents.Get(ctx, id) — fetch a stored document.package main
import ( "context" "fmt" "os"
polipage "github.com/poli-page/sdk-go" "github.com/poli-page/sdk-go/option")
func main() { ctx := context.Background() client := polipage.NewClient( option.WithAPIKey(os.Getenv("POLI_PAGE_API_KEY")), )
doc, err := client.Documents.Get(ctx, "doc_abc123") if err != nil { panic(err) }
fmt.Printf("Document %s: %d pages, created %s\n", doc.DocumentID, doc.PageCount, doc.CreatedAt)
// PresignedPDFURL has a 15-minute TTL. Call DownloadPDF to fetch bytes // before it expires, or call Documents.Get again to refresh. pdf, err := doc.DownloadPDF(ctx) if err != nil { panic(err) } fmt.Printf("Downloaded %d bytes\n", len(pdf))}