Skip to content

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.

NameTypeRequiredDescription
ctxcontext.Contextrequired(no description)
idstringrequired(no description)
opts...option.RequestOption—(no description)

*DocumentDescriptor, error

CodeWhen
DOCUMENT_NOT_FOUNDNo stored document matches the supplied id.
DOCUMENT_GONEThe document was deleted or has expired.
INVALID_API_KEYThe API key is malformed or revoked.
INTERNAL_ERRORAPI returned 5xx. Retryable.
// 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))
}