cURL requests examples

Piotr Gankiewicz edited this page Dec 4, 2016 · 1 revision

Initialize.

curl http://localhost:5000/init -H "Content-Type: application/json" -X POST -d '{"username": "root", "password": "secret"}'

Create a new user.

Replace API_KEY.

curl http://localhost:5000/users -H "Authorization: Bearer API_KEY" -H "Content-Type: application/json" -X POST -d '{"username": "user1", "password": "secret"}'

Create a new box.

Replace API_KEY.

curl http://localhost:5000/boxes/default -H "Authorization: Bearer API_KEY" -H "Content-Type: application/json" -d '{}' -X POST

Add user to the new box.

Replace API_KEY.

curl http://localhost:5000/boxes/default/users -H "Authorization: API_KEY" -H "Content-Type: application/json" -X POST -d '{"username": "user1", "role": "boxuser"}'

Set user permissions in the new box.

Replace API_KEY.

curl http://localhost:5000/boxes/default/users/user1/permissions -H "Authorization: API_KEY" -H "Content-Type: application/json" -X PUT -d '["readentrykeys", "readentry", "createentry", "deleteentry"]'

Add appsettings entry to the new box.

Replace API_KEY and ENCRYPTION_KEY.

curl http://localhost:5000/boxes/api/entries -H "Authorization: Bearer API_KEY" -H "Content-Type: application/json" -H "X-Encryption-Key: ENCRYPTION_KEY" -X POST -d '{ "key": "appsettings", "value": { "database": { "connectionString": "secret-connection-string", "port": 1234 }, "email": { "apikey": "secret-api-key", "apiUrl": "api.email-provider.com" }}}'

Get appsettings entry from the new box.

Replace API_KEY and ENCRYPTION_KEY.

curl http://localhost:5000/boxes/default/entries/appsettings -H "Authorization: API_KEY" -H "X-Encryption-Key: ENCRYPTION_KEY"

Get a new box.

Replace API_KEY.

curl http://localhost:5000/boxes/default -H "Authorization: API_KEY"