API Reference ============= The AskHandle API is organized around `REST`_. Our API has predictable, resource-oriented URLs, and uses HTTP response codes to indicate API errors. .. _REST: https://en.wikipedia.org/wiki/Representational_State_Transfer Authentication -------------- Authenticate your account when using the API by including your secret API key in the request. Your API key carry many privileges, so be sure to keep them secret! Do not share your secret API key in publicly accessible areas such GitHub, client-side code, and so forth. To use your API key, include it in the Authorization HTTP header. The key should be prefixed by the string literal "Token", with whitespace separating the two strings. For example: :: Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b The `curl`_ command line tool may be useful for testing token authenticated APIs. For example: .. _curl: https://curl.haxx.se/ :: curl -X GET https://dashboard.askhandle.com/api/v1/ \ -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' Retrieving a Token (API key) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ When POST’ing to https://dashboard.askhandle.com/api/v1/auth/api-token with the following data (assuming this username / password exists): ``{"username": "test", "password": "test"}`` :: curl -X POST https://dashboard.askhandle.com/api/v1/auth/api-token \ -H 'Content-Type: application/json' \ -d '{"username": "test", "password": "test"}' you’ll receive something that looks like the following: :: {'token': '9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'} API Diagram ----------- .. image:: _static/chatbot_api.svg :width: 100% Resources --------- Lead ^^^^ **The lead object** ================== ======================= Attributes =========================================== uuid string, *UUID* nickname string, email string, *Email* phone_number string, device string, from_page_title string, referrer string, created_at string, ================== ======================= **Available methods** * **list:** ``GET /api/v1/leads/`` List all your leads. * **create:** ``POST /api/v1/leads/`` Create a new lead. * **retrieve:** ``GET /api/v1/leads//`` Show the details of a specific lead. * **update:** ``PUT /api/v1/leads//`` Update all fields of a specific lead. * **partial** update: ``PATCH /api/v1/leads//`` Update a field of a specific lead. * **destroy:** ``DELETE /api/v1/leads//`` Delete a specific lead. **Available filters** Add GET parameters to your request in following format: * **start_date:** ``?start_date=YYYY-MM-DD``. * **end_date:** ``?end_date=YYYY-MM-DD``. * **start_date&end_date:** ``?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD``. * **limit:** ``?limit=``. Message ^^^^^^^ **The message object** ================= ================================ Attributes =================================================== uuid string, *UUID* nickname string email string, *Email* phone_number string body string is_support_sender boolean sent_at datetime *room* *Room object* (for POST request) ================= ================================ **Available methods** * **list:** ``GET /api/v1/messages/`` List all your messages. * **create:** ``POST /api/v1/messages/`` Create a new message. * **retrieve:** ``GET /api/v1/messages//`` Show the details of a specific message. **Example Request** Create a new message in an existing room:: curl -X POST https://dashboard.askhandle.com/api/v1/messages/ \ -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' \ -H 'Content-Type: application/json' \ -d '{ "body": "Hello!", "email": "mary@example.com", "nickname": "Mary", "room": { "uuid": "de1e39a5-a391-4d7f-836d-cf3589529af8" } }' **Example Response** :: { "uuid": "ffb84155-5f12-4bee-bd50-3c868097e473", "nickname": "Mary", "email": "mary@example.com", "body": "Hello!", "is_support_sender": false, "sent_at": "2021-09-15T12:08:50.676405Z" } Room ^^^^ **The room object** ========== ============== Attributes ========================== label string uuid string, *UUID* name string rating integer, *1..5* is_bot_use boolean created_at datetime messages array ========== ============== **Available methods** * **list:** ``GET /api/v1/rooms/`` List all your rooms. * **create:** ``POST /api/v1/rooms/`` Create a new room. * **retrieve:** ``GET /api/v1/rooms/