Log in to a database session

To log in to a hosted database, use an HTTP POST method with the sessions API endpoint specifying the name of a hosted database. The account name and password are specified in a header Authorization string. If the account name and password are authenticated, your code receives an access token that defines your connection to the database. This connection is called a database session.

HTTP method

POST

URL

/fmi/data/version/databases/database-name/sessions

version – the FileMaker Data API version requested can use v1, v2, or vLatest

database-name – the name of the hosted database

HTTP headers

Content-Type: application/json

Authorization: Basic account:password

  • account:password - The base64-encoded string representing the account name, a colon (:), and the password used to log in to the hosted database. This follows the standard HTTP Basic authentication scheme. For example, if the account name is admin and the password is admin, then this value is the base64-encoded value of admin:admin, which is YWRtaW46YWRtaW4=.

    In this example, the value of the Authorization header is:

    Basic YWRtaW46YWRtaW4=

Parameters

An empty set of curly braces. For example: { }

May optionally use the fmDataSource parameter to log in to an external data source. See Log in to an external data source.

Response

The access token, a response body with the access token, and a messages array showing an error code of 0.

The X-FM-Data-Access-Token header is returned in response, which is the session token to be used for subsequent API calls.

For example:

Copy
Header
X-FM-Data-Access-Token: c4d2e429122e9cdeda19bb23c55cd2a8f282c3cc50c60943a110
Copy
Body
{
  "response": {
    "token": "c4d2e429122e9cdeda19bb23c55cd2a8f282c3cc50c60943a110"
  },
  "messages": [
    {
      "message": "OK"
      "code": "0"
    }
  ]
}

See Error responses.