-
Notifications
You must be signed in to change notification settings - Fork 7
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 } |
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.
- 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
Request formats | JSON |
Requires authentication? | Yes |
owner | integer only |
Name | Required | Description | Default Value | Example |
---|---|---|---|---|
name | required | Created account's name | "mynewaccount" |
|
owner | required | Owner of the account. Integers only | 2 |
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
}'
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
}