Overview

APIs

Topics

Auth

The following methods are available over the Web API:

Method Description
token.exchange Exchange a code for an access token during authorization
token.revoke Revoke an existing access token
permissions Lists the permissions granted to your access token

Web API token.exchange

Generates an access token during the authentication flow.

Method URI https://api.fieldmargin.com/v1/token.exchange
HTTP Method POST
Required scopes None

Request

Example request

code=8e238cff0e2f40b7b0fea3629d7f5738&client_id=dbb01ddf193c4a8c&client_secret=4524ae377d4a4a7599b5be56e7a8a630

This request does not require authentication. It must be sent with a application/x-www-form-urlencoded query string or POST body, with the following parameters:

Field Description
client_id The client ID of your integration
client_secret The client secret of your integration
code The code provided to you during authorization

Response

Example response

{
    "access_token": "b0ac977a46174334ad453ed9f515a38e",
    "farm_id": "76530ceb-6720-4a1e-a28d-124cbee922c9"
}

The response contains the following:

Field Description
access_token The access token for you to use to access the farm using the Web API
farm_id The ID of the farm you have connected to, for identifying requests from the Data API

Web API token.revoke

Revokes an existing access token, disconnecting an integration from a farm.

Existing farm data that the integration created will not be removed.

Method URI https://api.fieldmargin.com/v1/token.revoke
HTTP Method POST
Required scopes None

Request

Example request

{
    "access_token": "ffcd87af1d6b4223a1507b915fbe0680"
}

This request does not require authentication.

Field Description
access_token The access token to revoke

Response

Example response

{
    "revoked": true
}

The response contains the following:

Field Description
revoked Whether an access token was revoked or not

Web API permissions

Returns the permissions granted to your access token. This is also a convenient way to check if an access token is valid.

If you require more scopes then you must send the user back through the authorization flow. New scopes will be added to your existing access token.

Method URI https://api.fieldmargin.com/v1/permissions
HTTP Method GET
Required scopes None

Request

This request requires no extra parameters, simply include your access token in the Authorization header.

Response

Example response

{
    "scopes": [
        "fields:read:all",
        "maps:write"
    ]
}

The response contains the following:

Field Description
scopes Scopes accepted by the user during the authorization flow