Optifeed

Optifeed API

Authentication

Sign in as an API user with the client credentials grant, and send the access token with each request.

Your system signs in as an API user. The sign-in gives an access token. Your system sends the access token with each request.

API users

An API user belongs to your company, not to a person. It has no expiry date. It continues to work when the person who created it leaves the company.

A user manager creates and revokes API users in the Optifeed web app, on Account > Optifeed API. The page shows the last sign-in and the last request of each API user. The Quick start gives the steps.

Use one API user for each system. Each API user has its own rate limit, and you can revoke one system and keep the others.

Get an access token

POST https://api.optifeed.com/v1/oauth/token

The token endpoint uses the OAuth 2.0 client credentials grant. Send the parameters as a form (application/x-www-form-urlencoded).

Parameter Required Value
grant_type Yes client_credentials
client_id Yes The client id of the API user.
client_secret Yes The client secret of the API user.
curl https://api.optifeed.com/v1/oauth/token \
  -d grant_type=client_credentials \
  -d client_id="$OPTIFEED_CLIENT_ID" \
  -d client_secret="$OPTIFEED_CLIENT_SECRET"

You can also send the client id and the client secret with HTTP Basic authentication:

curl https://api.optifeed.com/v1/oauth/token \
  -u "$OPTIFEED_CLIENT_ID:$OPTIFEED_CLIENT_SECRET" \
  -d grant_type=client_credentials

The answer is 200 OK:

{
  "access_token": "ofo_EXAMPLE",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "read",
  "created_at": 1796029200
}
Field Value
access_token The access token. It starts with ofo_.
token_type Always Bearer.
expires_in The lifetime of the token in seconds: 3600, one hour.
scope The scope of the token. The API does not use it.
created_at The time of the sign-in, in Unix seconds.

The token is always for the company of the API user, and for this API only.

Token lifetime

An access token is valid for one hour. Optifeed gives no refresh token. To continue after the hour, sign in again with the same request.

  • Each sign-in gives a new access token. The earlier tokens stay valid until they expire.
  • Use one token for its full hour. Do not sign in before each request, because the token endpoint accepts only 30 sign-ins in one minute from one IP address.
  • Sign in again when expires_in ends, or when a request gets 401 with the code token_expired. Then send the request again.

Send the access token

Send the access token in the Authorization header of each request:

Authorization: Bearer ofo_EXAMPLE
  • Write the scheme Bearer in uppercase or lowercase.
  • Put one space between Bearer and the token.
  • Send the token only in this header.

The access token works only on https://api.optifeed.com/v1. The Optifeed web app and the Optifeed MCP server refuse it. Another Optifeed token, for example a personal access token or the token of an MCP client, gets 403 with the code token_not_accepted.

Limit an API user to IP addresses

A user manager can limit an API user to a list of IP addresses. Open Account > Optifeed API. Write the list when you create the API user, or click Edit on its row later.

  • Write one IPv4 or IPv6 address or range on each line, for example 203.0.113.5 or 198.51.100.0/24. The list has 100 entries at most.
  • An empty list accepts each IP address. The list of the API users page shows All IPs then.
  • The sign-in and each request check the IP address, also GET /v1/health. A request from another IP address gets 403 with the code ip_not_allowed. The message names the IP address that Optifeed saw, so you can add it to the list.
  • A change of the list applies at once, also to the access tokens that the API user got before the change.
  • Use the public IP address of your system. A system behind a NAT or a proxy sends from the address of that NAT or proxy.
  • A refused IP address with the right client secret does not count as a failed sign-in.

Revoke an API user

A user manager revokes an API user in the web app. Open Account > Optifeed API, then click Revoke on the row of the API user.

After a revoke:

  • Each access token of the API user stops at its next request. The answer is 401 with the code token_revoked.
  • A sign-in of the API user gets 401 with the error invalid_client.

You cannot undo a revoke. To connect the system again, create a new API user.

Refusals of the company

Optifeed checks the company of the API user at each sign-in and at each request.

Code Status Meaning
company_inactive 403 The company is not active.
company_pending_approval 403 The company waits for approval.
trial_ended 403 The trial of the company ended. Choose a plan in the web app.

When the cause goes away, the same API user and its valid tokens work again.

Two error shapes

The token endpoint uses the OAuth 2.0 error shape, so an OAuth client library can read it:

{
  "error": "company_inactive",
  "error_description": "The company of the API user is not active."
}

The other endpoints use the error shape of the API, with an error object and a request_id. Errors gives the two shapes and each code.

Keep the client secret safe

  • Keep the client secret on your server, for example in an environment variable or a secret store.
  • Do not put the client secret in a browser, in a mobile app or in a code repository.
  • Optifeed keeps only a hash of the client secret, so Optifeed cannot show it to you again.
  • If the client secret leaks, revoke the API user at once and create a new one.