API

Learn how to use the API functionality while creating a task in DBSync Cloud Workflow

The API feature in DBSync Cloud Workflow allows seamless integration between the DBSync platform and external systems or applications. By using REST API methods, users can manage data flows, automate tasks, and trigger workflows across multiple applications, including CRMs, ERPs, and other business tools.

APIs enable users to:

  • Customize and extend the functionality of DBSync workflows using custom API scripts.

  • Create, read, update or delete records from external systems.

  • Automate repetitive tasks.

  • Fetch and send data to and from third-party applications.

API Functions and Usage

DBSync API supports various HTTP methods to interact with data. Below are common operations:

API Methods:

  1. GET Retrieve data from DBSync or an external application.

    • Example:

      bashCopy codeGET https://api.dbsync.com/v1/records
  2. POST Create new records or trigger workflows.

    • Example:

      bashCopy codePOST https://api.dbsync.com/v1/records
      Body:
      {
        "field1": "value1",
        "field2": "value2"
      }
  3. PUT Update existing records.

    • Example:

      bashCopy codePUT https://api.dbsync.com/v1/records/123
      Body:
      {
        "field1": "newValue1"
      }
  4. DELETE Delete records or cancel workflows.

    • Example:

      bashCopy codeDELETE https://api.dbsync.com/v1/records/123

Configure the API Connection

Follow the steps given below to configure the API connection;

  1. Once logged in, navigate to the Apps > Open API.

  2. You will be redirected to the Quick Setup tab in the Open API configuration page.

  3. The following fields are available in this tab;

  • Authentication Type: API authentication is the process of verifying the identity of a user or system making a request to an API. This is crucial for ensuring that only authorized users can access the API and its resources. Here are some common types of API authentication:

    • NoAuth: NoAuth refers to a scenario where no authentication is required. This means that anyone can access the resource without providing any credentials. It’s often used in public APIs or services where security is not a concern.

    • BasicAuth: Basic Authentication is a simple authentication scheme built into the HTTP protocol. The client sends HTTP requests with the Authorization header that contains the word Basic followed by a space and a base64-encoded string username:password. For example, Authorization: Basic ZGVtbzpwQDU1dzByZA==. It’s important to use BasicAuth over HTTPS to ensure the credentials are encrypted.

    • OAuth: OAuth 2.0 stands for Open Authorization and is a standard designed to allow a website or application to access resources hosted by other web apps on behalf of a user. It provides consented access and restricts what the client app can do on behalf of the user without sharing the user’s credentials. OAuth 2.0 uses access tokens to grant access to resources.

    • Bearer: Bearer Authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens. The name Bearer authentication can be understood as give access to the bearer of this token. The bearer token is a cryptic string, usually generated by the server in response to a login request. The client must send this token in the Authorization header when making requests to protected resources: Authorization: Bearer.

  • API URL: An API URL (Uniform Resource Locator) is the specific web address used to access and interact with an API (Application Programming Interface). It typically consists of a base URL and an endpoint. The base URL is the main address of the API, while the endpoint specifies the particular resource or action you want to access. For example, in the URL https://api.example.com/users, https://api.example.com is the base URL, and /users is the endpoint that might return a list of users.

  • API Json: API JSON is a way to send and receive data using a format called JSON. JSON looks like a list of key-value pairs, which makes it easy to read and understand.

  1. Provide the details in the above mentioned fields as required and click Validate Connection to validate the connection of the API.

  2. Click Connect and Save Connection to establish the connection.

Additional Information

Field Validation

APIs perform automatic validation for required fields, data formats, and unique constraints.

  • If a required field is missing, the API will return a validation error.

  • Ensure that the data type (string, integer, etc.) matches the expected format for each field.

Error Handling

If an error occurs during an API request, the response will include an error code and message.

  • Common Error Codes:

    • 400: Bad Request (validation error)

    • 401: Unauthorized (invalid API key)

    • 404: Not Found (resource doesn’t exist)

    • 500: Internal Server Error (server issues)

  • Sample Error Response:

    jsonCopy code{
      "error": {
        "code": 400,
        "message": "Invalid field value"
      }
    }

Monitoring API Usage

Logs and Tracking

DBSync Cloud Workflow provides detailed logging for API activity, including successful requests and errors.

  • To view logs:

    1. Navigate to API Logs under the Monitoring section.

    2. Filter logs by date, API method, or endpoint.

    3. Export logs if needed for auditing purposes.

API Limits and Rate Throttling

DBSync enforces API rate limits to prevent abuse and ensure smooth operation.

  • Limits:

    • A specific number of requests per minute/hour depending on your subscription tier.

    • If the limit is exceeded, a 429 Too Many Requests response will be returned.

Best Practices

  • Use Pagination: For large datasets, always paginate API responses using query parameters such as limit and offset.

  • Batch Operations: For efficiency, use batch requests for creating or updating multiple records at once.

  • Secure Your API Keys: Never share your API keys publicly. Rotate them regularly and revoke unused keys.

  • Error Logging: Implement proper error logging and monitoring to troubleshoot issues effectively.

Troubleshooting

  • Issue: API key is not working.

    Solution: Ensure the key is correct and has the proper permissions. Check if the key has expired or been revoked.

  • Issue: Receiving 401 Unauthorized errors.

    Solution: Verify that the API key is included in the header and is valid.

  • Issue: Invalid Data Errors (400 Bad Request).

    Solution: Ensure all required fields are included in the request body, and data types are correct.

Frequently Asked Questions (FAQ)
  1. Can I regenerate my API key? Yes, you can regenerate an API key from the API Management section. Make sure to update your integrations with the new key.

  1. How do I test my API calls? You can use tools like Postman or Curl to test your API requests before integrating them into your application.

  1. Are there limits on the number of API requests? Yes, DBSync enforces rate limits based on your subscription plan. You can view your API usage in the API monitoring section.

  1. Can I access historical data through the API? Yes, you can retrieve historical data by specifying the date range in your API queries using query parameters.

Last updated