Sign-up and login screens are often built before the identity service is ready. The auth template gives you the four calls such screens need behind a real URL, so you can build forms, token handling and the signed-in state of your app. It imitates the shape of a sign-in API; it does not authenticate anyone.
What you get
The template creates a project with the base path /auth-api and 4 endpoints. Each endpoint has one ready response, so the API answers as soon as the project exists.
| Method | Path | What it answers |
|---|---|---|
POST |
/register |
201 with name and email from the request body and a generated id. |
POST |
/login |
200 with a random opaque accessToken and a user. |
GET |
/me |
200 with a generated user. |
POST |
/logout |
204 without a body. |
POST /register answers with id, name, email, emailVerified (false) and createdAt. POST /login answers with accessToken, tokenType (Bearer), expiresIn (3600) and a user with id, name and email. GET /me returns id, name, email, role (admin or member), avatarUrl, emailVerified and lastLoginAt. A password you send is never part of a response.
Sample response
$ curl -s -X POST $URL/auth-api/login \
-H "Content-Type: application/json" \
-d '{"email":"mira@example.com","password":"example"}'
{
"accessToken": "<64 random hex characters>",
"tokenType": "Bearer",
"expiresIn": 3600,
"user": {
"id": "0b6f2c1e-7a4d-4e9b-9c3a-5d8e1f2a6b7c",
"name": "Jonas Reed",
"email": "mira@example.com"
}
}
email comes from your request. The token, the user's id and the name are generated on every call, so two logins with the same email return two different tokens and names.
How to start
- Sign up at
https://app.mockhop.com/register. The quickstart explains the account and the address of your organization. - Open Projects and select Start from a template.
- Choose Example auth API and select Use template.
Then call the mock. Replace acme with your organization's address. Your mocks answer from outside once you've confirmed your email address.
$ URL=https://acme.mockhop.cloud
$ curl -s -X POST $URL/auth-api/register \
-H "Content-Type: application/json" \
-d '{"name":"Mira Keller","email":"mira@example.com"}'
$ curl -s $URL/auth-api/me
The first call answers 201 with the name and email you sent. The second returns a generated user, with or without an Authorization header.
What to do next
- Change the responses. Open an endpoint and edit the status code, headers and body of its response, or add more responses with matching rules.
- Add error cases and delays. For example a
401for wrong credentials onPOST /loginor a409for an email that is already registered. A matching rule on a header or a body field lets your test choose the case. See Simulate API errors, timeouts and rate limits. - Use scenarios for flows. For example
GET /methat answers200first and401on the next call, to test what your app does when a session ends. See Scenarios; scenarios are included from the Pro plan. - Export the project. Under Import/Export you can download the project as an OpenAPI 3.0 file.
Good to know
- The template performs no real authentication.
POST /loginaccepts any email and any password, also an empty body, and always answers200. - The access token is a random opaque string made for each answer. It is not stored and no endpoint checks it:
GET /meanswers the same way with any token or with none. - Responses are generated per request and the mock keeps no state. The account from
POST /registeris not the user thatPOST /loginorGET /mereturns, andPOST /logoutends nothing. - Use it to build and test sign-in screens and client-side token handling. It protects nothing, and you shouldn't send real passwords to a mock.
- The template creates a new project, and no other project in your organization may use the base path
/auth-api. The Free plan includes one project. - You can change or delete the project and each of its endpoints at any time.
New to Mockhop? Start with the quickstart. Plans: pricing.