Skip to content

Documents.Delete

func (d *Documents) Delete(ctx context.Context, id string, opts ...option.RequestOption) error

Delete soft-deletes a stored document. The PDF is purged from storage; metadata is retained for audit. Deleting an already-deleted document also succeeds: the API answers 204 either way.

Spec §6.4.

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

error

CodeWhen
DOCUMENT_NOT_FOUNDNo stored document matches the supplied id.
ENVIRONMENT_PROTECTEDThe environment is protected: this key may not delete its documents.
INVALID_API_KEYThe API key is malformed or revoked.
INTERNAL_ERRORAPI returned 5xx. Retryable.
// Demonstrates: client.Documents.Delete(ctx, id) — soft-delete 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() {
client := polipage.NewClient(
option.WithAPIKey(os.Getenv("POLI_PAGE_API_KEY")),
)
if err := client.Documents.Delete(context.Background(), "doc_abc123"); err != nil {
panic(err)
}
// Returns nil. The PDF is purged; metadata is retained for audit.
fmt.Println("Deleted.")
}