The first rule of fight cl.. using the Captain Data API to manage users is to synchronize your SaaS users to your Captain Data's workspace.
Adding users & accounts
Add a new User
One user on your SaaS = one user on Captain Data.
Whenever you want your user(s) to be able to automate something, you need to use the POST request Add a new User.
https://api.captaindata.co/v3/users
With the following body:
{
"email": "test@test.co",
"full_name": "Test Test",
"country": "FR"
}
⚠️ Important note: you can and should always pass a specific "country" as it will provision a proxy IP within this zone that we'll attach to this user.
Therefore, the “country” selected must match the location where you are when you log into your social media account to avoid any restrictions (e.g.: LinkedIn).
Exercise caution when using a VPN. Either choose the exact same country where your VPN provides IPs to ensure a match, or log out from your VPN when logging into your Social Media Account.
--
You can use any Iso2Code except the following:
"MG","RE","CI", "NA", "CV", "MU", "HN", "UY", "XK", "GN", "UA", "BB", "PF", "QA", "KY", "ly", "LB", "VE", "UG"
This ensures safe automation throughout the life of the user.
Once you've got a user, you can create and attach an account to it.
Add or Update Integration Account
https://api.captaindata.co/v3/integrations/:integration_uid/accounts
With the following body:
{
"account": {
"uid": "Pass this field to update an existing account (it will create the account otherwise)",
"name": "New account",
"api_key": "",
"username": "",
"password": "",
"cookies": {
"li_at": "YOUR_SESSION_COOKIE"
},
"user_uid": "User's uid to link the account to"
}
}
You don't need every field, it comes down to which application you're using.
Let's take the case of LinkedIn, the previous POST URL would become:
https://api.captaindata.co/v3/integrations/linkedin/accounts
And the body to use:
"account": {
"name": "New account",
"user_uid": "uid_of_a_user",
"cookies": { "li_at": "YOUR_SESSION_COOKIE" }
}
Pretty simple right?
⚠️ Important note: for LinkedIn Sales Navigator accounts, make sure to send the "li_a" field in addition to "li_at" otherwise the connection won't hold.
Make sure to save the "account_uid" returned from the POST inside your own User database model to easily trigger automation from your back-end!
You can use this UUID when launching Jobs, checkout the POST endpoint Launch a Workflow.
Updating Accounts
🚨 Do not skip this step if you're automating LinkedIn!
Normally you'd use the Captain Data's Chrome Extension to automatically refresh cookies.
If you're developing your own Chrome Extension, make sure to keep your user's cookies up-to-date at any time to avoid service disruption.
Follow our article Building Chrome Extensions Best Practices to learn more.
You can just use the same endpoint as previously, POST method Add or Update Integration Account to update any account.
By providing the account_uid we'll know the account already exists.
Pass the new cookie value, for example, which we'll use to make sure automations run smoothly.
Deleting Accounts
Think about removing the user on Captain Data if you delete it from your app :)
Use the DELETE endpoint "Remove User".
Enabling auto-billing with the API
You can choose to automatically provision user licenses using the API.
Under My Account > Users > Settings you can check the box "Enable users management from the API".
By default, the maximum is 0 which is an unlimited number of licenses:
⚠️ Note that this will dynamically change and upgrade your subscription the more users you add.
You can add a maximum number of workspace users to avoid surprises :)