Skip to content

post accounts

Harmun edited this page May 15, 2019 · 3 revisions

post /accounts User Add new account to db { name, owner } { id, name, owner, deletedAt, lastUpdated, balance }

POST accounts

Creates a new account with a name, and links it to the owner using the user's ID. Accounts are assigned their own IDs on creation.

Restrictions

  • Balance of the account defaults to 0.
  • The owner field must be an integer
  • Only an existing user can be the owner of a newly created account

Resource Information

Request formats JSON
Requires authentication? Yes
owner integer only

Fields

Name Required Description Default Value Example
name required Created account's name "mynewaccount"
owner required Owner of the account. Integers only 2

Example Request

curl -X POST \
  http://localhost:3000/accounts \
  -H 'Authorization: Bearer 123testtoken123' \
  -H 'Content-Type: application/json' \
  -H 'Host: localhost:3000' \
  -d '{
	"name" : "infinityglove2",
	"owner" : 2
}'

Example Response

After you post successfully you should get back the created account's information like this:

{
    "id": 2,
    "name": "infinityglove2",
    "owner": 2,
    "deletedAt": null,
    "lastUpdated": "2019-05-15T09:23:42.000Z",
    "balance": 0
}
Clone this wiki locally