Search code examples
c#stitch

How to create an import-api integration with an access token through connect api?


Stitch offers a connect API, which you can use to make actions on behalf of other clients, if you're a stitch partner. (Otherwise with the connect API you have access only to your own account)

With their Connect API, we can create an Import API integration, by calling the source endpoint (https://www.stitchdata.com/docs/stitch-connect/api#create-a-source), but for some reason, it is created without an Import API access token (the user has to manually create it for said integration).

How can I create such a token on their behalf, without forcing them to go to their account and generate and copy said Import API Access token?

Don't confuse the Connect API access token to that of their integration's import API access token. Each Import API integration in their account can have up to 2 import API access tokens generated/used.

I've read everything there is for Stitch's Import API, as well as Connect API, and I also believe this to have been working before, but for some reason it's returning the source object without any access tokens in their properties field.

Resources:

  1. https://www.stitchdata.com/docs/stitch-connect/api
  2. https://www.stitchdata.com/docs/integrations/import-api/

Solution

  • This is undocumented as of now, but here's how to do it:

    1. Use the Sources endpoint to add the Import API (docs) as a source
    2. As a sub-step, you will need to request a token specific to the Import API source you create by POSTing to the /tokens endpoint for that source. Keep this token associated with this specific account.
    3. POST https://api.stitchdata.com/v4/sources/{connectionID}/tokens
    4. With the Token created from the Import API endpoint, you can post JSON to the Import-API endpoint and it will automatically parse and load this data.