Manage Account

Creating a new account

To start interacting with ApiHub, it’s needed to create a user account. Follow below an example, using CURL, of how to create a user account:

Resource URL

http://localhost:8000/api/users

Resource Information

Response formatJson
Requires authentication?No

Payload Parameters

ParameterTypeRequired?Unique?
nameStringYesNo
emailStringYesYes
passwordStringYesNo

Example Request

curl -XPOST -i http://localhost:8000/api/users -H "Content-Type: application/json" -d '{"name": "Alice", "email": "[email protected]", "username": "alice", "password": "123"}'

Example Result

HTTP/1.1 201 Created
Content-Type: application/json
Request-Id: aleal.local/E8z3MiQMuT-000001
Date: Sat, 06 Dec 2014 01:28:31 GMT
Content-Length: 60

{
	"name":"Alice",
  "email":"[email protected]",
  "username":"alice"
 }

On the other hand, if there’s a validation error, for example: someone else already has that email, the response looks like:

HTTP/1.1 400 Bad Request
Content-Type: application/json
Request-Id: aleal.local/E8z3MiQMuT-000002
Date: Sat, 06 Dec 2014 01:28:39 GMT
Content-Length: 90

{
	"error":"bad_request",
  "payload":"Someone already has that email/username. Could you try another?."
}

Deleting a user account

The only way to remove a user account is by using a valid Token. For this, it’s neeeded to log in with the ApiHub credentials to gain a valid Token. If you want to see how to log in, see Log in with ApiHub Credentials.

🚧

Warning

This action cannot be undone. Once you remove your user, all the teams and services which you are the only member are deleted along with your account.

Resource URL

http://localhost:8000/api/users

Resource Information

Response formatJson
Requires authentication?Yes

Header Parameters

ParameterTypeRequired?
AuthorizationStringYes

Example Request

curl -i -XDELETE http://localhost:8000/api/users -H "Authorization: Token 1-PYXC0NE5OxrryQ4DmZ_C2WOwAlAOc-uyEKcPW0nr8="

Example Result

The API returns the resource itself whenever possible. Even after deleting a user, the response payload will be the user:

HTTP/1.1 200 OK
Content-Type: application/json
Request-Id: aleal.local/qJJjhtuJc3-000003
Date: Sat, 06 Dec 2014 01:39:20 GMT
Content-Length: 59

{
	"name":"Alice",
	"email":"[email protected]",
	"username":"alice"
}

If trying to delete an account with a invalid token, the result will be the following.

HTTP/1.1 401 Unauthorized
Content-Type: application/json
Request-Id: aleal.local/Zh86HQSRtD-000005
Date: Tue, 23 Dec 2014 17:13:49 GMT
Content-Length: 73

{
	"error":"unauthorized_access",
	"error_description":"Request refused or access is not allowed."
}