Examples
This bash script demonstrates a complete FTP account CRUD workflow using HTTPie and jq.
The example performs the following operations:
- Authenticate against the Management API
- Create a new FTP account
- Retrieve the account
- Update the account
- Retrieve the updated account
- Delete the account
Requirements
Install:
Full Example
#!/bin/bash
#
# Authenticate and retrieve Bearer token
#
TOKEN=$(http --body POST https://api.ftpgrid.com/apiaccess/auth \
AssociationKey="YOUR_ASSOCIATION_KEY" \
AccessKey="YOUR_ACCESS_KEY" \
SecretKey="YOUR_SECRET_KEY" | jq -r '.token')
echo "Access token: $TOKEN"
#
# Create FTP account
#
ID=$(http POST https://api.ftpgrid.com/ftpaccounts/auto \
Authorization:"Bearer $TOKEN" | jq -r '.ID')
echo "FTP Account ID: $ID"
#
# Retrieve FTP account
#
http GET https://api.ftpgrid.com/ftpaccounts/id/$ID \
Authorization:"Bearer $TOKEN"
#
# Update FTP account
#
http PATCH https://api.ftpgrid.com/ftpaccounts \
Authorization:"Bearer $TOKEN" \
Id:=$ID \
Description="Updated using CLI"
#
# Retrieve updated FTP account
#
http GET https://api.ftpgrid.com/ftpaccounts/id/$ID \
Authorization:"Bearer $TOKEN"
#
# Delete FTP account
#
http DELETE https://api.ftpgrid.com/ftpaccounts/id/$ID \
Authorization:"Bearer $TOKEN"
echo "FTP account deleted"
Notes
- The
/ftpaccounts/autoendpoint automatically generates a secure username and password - The generated FTP account can immediately be used with FTP, FTPS, SFTP, and SCP
- The
Authorizationheader must contain a valid Bearer token - Passwords are never returned by the API after creation