Short link creation and management

Go to CloudFormation service in your AWS Console.

Choose the stack you created for the Telegram bot (Bot and API Setup section in Setup instructions).

To work with the API, use the HttpApiUrl from the Outputs tab. For example, 


All commands must contain an authorization token in the header. To get it, you need to make a POST request /login

Username and password were defined when the bot stack was used. 

curl -d '{"username":"","password":"pass"}' -H "Content-Type: application/json" -X POST

If successful, the responce will contain the 'AccessToken' field

{"success": true, "message": "Auth ok", "items": [], "auth": {"AccessToken": "eyJraWQ...5EuFopT80A", "ExpiresIn": 3600, "TokenType": "Bearer"}}



All other queries have to go to the endpoint '/colinks' 

GET allows you to get the current list of the short links.

curl -H "Authorization: Bearer eyJraWQ...80A"

sample response: 

{"lastKey": 0, "items": [{"short": "test", "full": ""}, {"short": "3edb46bc", "full": ""}]}

POST allows you to create new short links. Specify a relative URL as "short" parameter, and target address as "full".

curl -d '{"short":"test", "full":""}' -H "Content-Type: application/json" -H "Authorization: Bearer AAAA...AAAA" -X POST

PUT /{id} query allows you to edit existing short links. Specify an existing short link instead of {id}, and a new target address as full.

curl -d '{"full":""}' -H "Content-Type: application/json" -H "Authorization: Bearer AAAA...AAAA" -X PUT

The delete /{id} query allows you to delete an existing short link.

curl -H "Content-Type: application/json" -H "Authorization: Bearer AAAA...AAAA" -X DELETE