# API and Authentication

### What is the difference between databaseId and Id?

The `Id` is the base64-encoded version of the `databaseId` with the ObjectType.&#x20;

In other words, `Id` = `ObjectType` + `:`  + `databaseId`

For example, if the `databaseId` for a recipe is b78a8f0d-4c89-4df1-bc73-42e2175e2737 then its iD would be UmVjaXBlOmI3OGE4ZjBkLTRjODktNGRmMS1iYzczLTQyZTIxNzVlMjczNw==

In Python, this would be done as follows:

```javascript
base64.b64encode(b"Recipe:b78a8f0d-4c89-4df1-bc73-42e2175e2737")
```

### When should I use a `DatabaseID`?

Use the `databaseID` to execute some of the queries and mutations. The `databaseID` parameter is the base64-encoded version of the ID of an element that can be either of a user or a recipe.&#x20;

For that reason, use the`databaseId` to send it as a `sg-user` parameter in the header. &#x20;

To get the [`databaseID`,](https://docs.suggestic.com/graphql/objects/common/user) execute the [`users`](https://docs.suggestic.com/graphql/query/queries/my-list) query and to replace in the mentioned variable as follows:

```graphql
{
  "Authorization": "Token replace_user_token",
  "sg-user": "c975dac5-4d23-b348-cb30-ec50b33c4f91"
}
```

Include the `databaseID` in the `sg-user` for all the queries that are executed on behalf of a user. For example:

Using it in the header:

* If you need to get the list of all users created with a specific token, it is only required to send the token parameter because we don't require to get the information of a specific user.
* If you need to generate a meal plan, it is required to send the `databaseID` in the header since it will be generated for a specific user.

Use it in a mutation:

* If you need to update your own recipe, you will need to pass the `databaseID` as a parameter on the [`updateOwnRecipe`](https://docs.suggestic.com/graphql/query/mutations/food-log/own-recipe/update-own-recipe) mutation.&#x20;
* &#x20;If you need to delete/remove your own [`Recipe`](https://docs.suggestic.com/graphql/query/mutations/food-log/own-recipe/remove-own-recipe).

### When should I use an `ID`?&#x20;

Use the ID when you The ID is the base64-encoded version of the `databaseId`. Use this ID to send it as a parameter within a query or a mutation.

Some common examples:

* To retrieve the information of a specific [`recipe`](https://docs.suggestic.com/graphql/query/queries/recipes/recipe-by-id)
* To retrieve the details of a particular [`program` ](https://docs.suggestic.com/graphql/query/queries/program/program-details)based on its ID.
* To update the status of a "day" on a [`journey`](https://docs.suggestic.com/graphql/query/mutations/journey/journey-status)

### What is the difference between JWT and API Token Authentications?

The JWT authentication is intended to be used on the client-side while the API token authentication **must be only used** on the server-side.

For more information, check the [Authentication ](https://docs.suggestic.com/graphql/graphql/authentication)documentation.

### When I should use the Suggestic-Partner token?

Partners/clients which have an isolated database will need to authenticate by using a different HTTP header named  `Suggestic-Partner.`&#x20;

For more information, check the [authentication ](https://docs.suggestic.com/graphql/graphql/authentication#clients-partners-api-token)documentation.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.suggestic.com/graphql/knowledge-base/faqs/api-and-authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
