Coffrify (Coffrify v0.9.0)
View SourceOfficial Elixir client for the Coffrify API.
Coffrify is encrypted file-transfer infrastructure. This SDK is the
canonical Elixir client and mirrors the JavaScript SDK
(@coffrify/sdk v0.9.0) feature-for-feature.
Quickstart
client = Coffrify.new(api_key: System.fetch_env!("COFFRIFY_API_KEY"))
{:ok, page} = Coffrify.Resources.Transfers.list(client, limit: 20)
{:ok, %{webhook: wh, secret: secret}} =
Coffrify.Resources.Webhooks.create(client,
name: "My CI",
url: "https://ci.example.com/hooks/coffrify",
events: ["transfer.created", "transfer.downloaded"]
)
IO.puts("Store this secret in your secret manager: " <> secret)Configuration
Pass options to new/1:
:api_key(required) — API key starting withcof_(or legacycfy_/fxa_).:api_url(default"https://api.coffrify.com") — override for staging or private deployments.:workspace_id— pin requests to a specific workspace. Defaults to the key's workspace.:timeout_ms(default30_000) — per-request timeout.:user_agent— custom User-Agent (defaults tocoffrify-elixir/0.9.0).:max_retries(default3) — number of retries whenretry_policyis not set.:retry_base_delay_ms(default500) — initial backoff delay.:retry_policy— customCoffrify.Runtime.Retry.Policy; overrides the legacy options above.:auto_idempotency(defaulttrue) — auto-generateIdempotency-Keyon POST/PUT/PATCH/DELETE.:idempotency_store— aCoffrify.Runtime.Idempotencyadapter for crash-safe replay.:idempotency_ttl_ms(default 24h) — how long cached idempotent responses are kept.:circuit_breaker— aCoffrify.Runtime.CircuitBreakerPID.:rate_limiter— aCoffrify.Runtime.RateLimitadapter (TokenBucketorLeakyBucket).:telemetry_metadata(default%{}) — static metadata merged into every:telemetry.execute/3payload.:finch_name— optional Finch pool name passed toReq.:hooks— keyword list of:before_request,:after_response,:on_retry,:on_errorcallbacks.
Summary
Types
@type request_method() :: :get | :post | :put | :patch | :delete
@type t() :: %Coffrify{ api_key: String.t(), api_url: String.t(), auto_idempotency: boolean(), circuit_breaker: pid() | atom() | nil, finch_name: atom() | nil, hooks: keyword(), idempotency_store: term() | nil, idempotency_ttl_ms: pos_integer(), rate_limiter: term() | nil, retry_policy: Coffrify.Runtime.Retry.Policy.t(), telemetry_metadata: map(), timeout_ms: pos_integer(), user_agent: String.t(), workspace_id: String.t() | nil }
Functions
Build a new Coffrify client.
Raises Coffrify.Error.InvalidApiKey when the provided API key does not
start with a known prefix (cof_, cfy_, fxa_).
@spec request(t(), request_method(), String.t(), term(), request_opts()) :: {:ok, term()} | {:error, Exception.t()}
Issue an HTTP request against the Coffrify API.
Returns {:ok, body} on a 2xx response, or {:error, %Coffrify.Error{}}
for every other outcome (4xx, 5xx, transport errors, circuit-open).
Examples
Coffrify.request(client, :get, "/transfers", nil, query: [limit: 10])
Coffrify.request(client, :post, "/webhooks", %{name: "ci", url: "..."})
@spec request!(t(), request_method(), String.t(), term(), request_opts()) :: term()
Same as request/5 but raises on error.
@spec version() :: String.t()
Return the static SDK version as a string.