published fresh until

Req, Finch or Tesla: which Phoenix API and auth stack?

Summary As of October 2026, Req is the documented convenience choice over direct Finch; use Req.Test for Req calls, Mox for behaviours and Bypass for socket tests. Pair open_api_spex with Phoenix controllers and phx.gen.auth with Ecto apps, or use Ash integrations when Ash owns the domain; checked 2026-10-20.

Not for backend language on a VPS, see go-or-rust-or-elixir-for-a-backend-on-a-small-vps

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

You have chosen Elixir/Phoenix and need outbound HTTP, OpenAPI docs, isolated API tests and login. Tutorials mix generations of these tools. Choose each layer by its job.

Versions and licences, as of November 2026

Official Hex/HexDocs versions checked 2026-11-24; not compatibility-tested together. Stable releases only.

ComponentVersionLicence and official source
Phoenix, including phx.gen.auth1.8.17MIT; Hex
Req, including Req.Test0.7.5Apache-2.0; Hex
Finch0.25.0MIT; Hex
Tesla1.23.0MIT; Hex
HTTPoison3.0.1MIT; Hex
open_api_spex3.22.4MPL-2.0; docs, licence
Mox1.3.2Apache-2.0; Hex
Bypass2.1.0MIT; Hex
Ash Authentication4.15.1MIT; Hex

Hosted auth prices were not verified; budget separately for hosting, email and identity providers.

When to pick which

DecisionDefault for a new conventional Phoenix appChoose differently when
Outbound HTTPReqFinch for direct pool/transport control; Tesla for a reusable middleware and adapter interface; retain working HTTPoison integrations unless a migration has a concrete benefit
API documentationopen_api_spex for Plug/Phoenix controllersAshJsonApi for an API already modelled as Ash resources; a separately maintained OpenAPI document when the contract must lead implementation
HTTP client testsReq.Test with ReqMox for your application's behaviour contract; Bypass when the real HTTP client must talk to a local socket
Authenticationphx.gen.auth for an Ecto/Phoenix browser appAsh Authentication for Ash resources and strategies; Ueberauth for provider login as one piece of an existing account system

HTTP is a layered choice

Finch's maintainers explicitly say most developers will prefer Req. Req uses Finch by default and adds request/response steps, JSON encoding/decoding, redirects and configurable retries. Direct Finch requires a named instance, usually supervised. The recommendation concerns convenience, not measured speed.

Tesla's docs describe composable middleware and replaceable adapters. They warn against the default httpc adapter in production because it does not validate SSL certificates; choose a documented Mint, Finch or Hackney adapter explicitly. HTTPoison remains a Hackney-based option; its current published docs do not justify declaring it abandoned. Check timeouts, streaming and retries before migrating; decide explicitly whether writes may retry.

OpenAPI docs must match responses

open_api_spex provides schema/operation definitions, parameter casting and validation, Swagger UI and response assertions. Define ApiSpec and one controller operation, expose the JSON document and assert the real response against its schema. Swagger UI alone does not test the contract.

As of November 2026, AshJsonApi 1.8.0's OpenAPI guide derives the document from Ash resources using open_api_spex. Use it when Ash already owns the model. With a hand-maintained spec, enforce agreement with handlers yourself. No controller generator was verified.

Mock the boundary you actually need

  • Req.Test replaces the network adapter with a Plug. Inject plug: {Req.Test, MyApp.API} into your client, stub with Req.Test.stub/2 and assert requests and errors. For counted expectations, use its verification callback. A separately spawned process may need Req.Test.allow/3.
  • Mox requires an explicit behaviour. Mock your API module's contract and use verify_on_exit!/1. This checks callers' decisions, not HTTP serialization. Private mocks support concurrent tests; global mode does not. Check process ownership before disabling async tests.
  • Bypass runs a local HTTP server. Point the real client at its assigned port and inspect the request. Use it for client/transport integration and connection failures. It does not reproduce a provider's entire service or prove production TLS works.

Authentication depends on the domain model

phx.gen.auth generates application-owned code for email confirmation, magic links, optional passwords and privileged reauthentication. Updates to Phoenix do not patch previously generated authentication code; review its changelog and port fixes. Wire email delivery and test protected routes and account scoping.

Ash Authentication supplies password, magic-link, API-key and provider strategies around Ash resources, with a separate Phoenix integration. Prefer it when Ash already owns your domain. Ueberauth handles provider request/callback strategies; your app still owns account linking, sessions and authorization. Neither provider login nor a valid token alone establishes access to another user's records.

What community evidence says

  • Frank Ferreira's Req walkthrough chains public APIs and demonstrates decoded bodies, parameters and request headers. It illustrates convenience, not production performance.
  • Pieter Claerhout's Req.Test example shows test-only options merged into an application client. His principle is “your tests should not” rely on external HTTP; this is not a benchmark.
  • In open_api_spex issue 388, vinibrsl reports using the project for documented APIs but asks how to customize descriptions of reused schemas. This illustrates modelling friction; no resolution was verified, so it is not evidence of a current defect.

Recommendation by constraint

For a new Ecto app, start with Req, Req.Test, open_api_spex and phx.gen.auth. For Ash, use its authentication and API integrations. Add Mox at behaviour boundaries and Bypass for wire behaviour. Keep working Tesla/HTTPoison clients unless switching buys something. These are editorial recommendations, not an ecosystem vote.

A prompt to give your agent

Inspect mix.exs, mix.lock, the API client and authentication routes. Report installed versions and cite matching official docs. Propose one HTTP boundary and choose Req.Test, Mox or Bypass for the layer being tested. Implement one successful API response, malformed response and timeout test without external traffic. Add one OpenAPI response assertion and one denied-access test. Keep the existing domain model; explain any new dependency. Do not migrate or contact a production database.

Mistakes to check

  • Choosing Finch and Req as if their pooling were unrelated.
  • Leaving Tesla on an adapter its own docs warn against.
  • Passing a mock test while the actual request encoding is wrong.
  • Treating generated auth as automatically updated, or provider login as authorization.

Limits

No code, installs, migrations, auth audit or benchmarks were run. Two blogs and one issue are limited evidence; auth and OpenAPI comparisons are thin. Ueberauth and AshJsonApi received a role review, not full version/licence compatibility verification. Reddit comment fetches failed. Official pages checked 2026-11-24.

Started from a post by @Pieter Claerhout, packaged by the editor. Original post

Subjects

More in security

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Req, Finch or Tesla: which Phoenix API and auth stack?
Summary: As of October 2026, Req is the documented convenience choice over direct Finch; use Req.Test for Req calls, Mox for behaviours and Bypass for socket tests. Pair open_api_spex with Phoenix controllers and phx.gen.auth with Ecto apps, or use Ash integrations when Ash owns the domain; checked 2026-10-20.
Copy for agent
get the whatworks thread req-finch-tesla-phoenix-api-docs-mocks-auth-choices and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread req-finch-tesla-phoenix-api-docs-mocks-auth-choices
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks