You are reading the documentation for an outdated Corteza release. 2023.9 is the latest stable Corteza release.

API

Node pairing

Create a federated node from a series of parameters

Used variables
# Base URL of node A api
$API_A_BASE

# Main administrator JWT for node A
$MAIN_JWT_A

# Node A domain
$DOMAIN_A

# Node B domain
$DOMAIN_B

# Node name
$NODE_NAME

# Node A nodeID
$NODE_ID_A

# Node B nodeID
$NODE_ID_B

# Node URI
$NODE_URI
Example request
curl -X POST "$API_A_BASE/federation/nodes/" \
  -H "authorization: Bearer $MAIN_JWT_A" \
  --header "Content-Type: application/json" \
  --data "{
    \"baseURL\": \"$DOMAIN_A_BASE_URL\",
    \"name\": \"$DOMAIN_A_NAME\"
}";
Example response
{
  "response": {
    "nodeID": "$NODE_ID_A",
    "name": "$DOMAIN_A_NAME",
    "status": "pending",
    "baseURL": "$DOMAIN_A_BASE_URL",
    "sharedNodeID": "$NODE_ID_A",
    "createdAt": "2020-12-01T14:24:47.246145938Z",
    "createdBy": "0"
  }
}

Create a federated node from a node URI

Used variables
# Base URL of node B api
$API_B_BASE

# Main administrator JWT for node B
$MAIN_JWT_B

# Node B domain
$DOMAIN_B

# Node A domain
$DOMAIN_A

# Node name
$NODE_NAME

# Node B nodeID
$NODE_ID_B

# Node A nodeID
$NODE_ID_A

# Node URI
$NODE_URI
Example request
curl -X POST "$API_B_BASE/federation/nodes" \
  -H "authorization: Bearer $MAIN_JWT_B" \
  --header "Content-Type: application/json" \
  --data "{
    \"baseURL\": \"$DOMAIN_B_BASE_URL\",
    \"name\": \"$DOMAIN_B_NAME\"
}";
Example response
{
  "response": {
    "nodeID": "$NODE_ID_B",
    "name": "$DOMAIN_B_NAME",
    "status": "pending",
    "baseURL": "$DOMAIN_B_BASE_URL",
    "sharedNodeID": "$NODE_ID_A",
    "createdAt": "2020-12-01T14:24:47.246145938Z",
    "createdBy": "0"
  }
}

Initialize the handshake

Used variables
# Base URL of node B api
$API_B_BASE

# Main administrator JWT for node B
$MAIN_JWT_B

# Node B nodeID
$NODE_ID_B
Example request
curl -X POST "$API_B_BASE/federation/nodes/$NODE_ID_B/pair" \
  -H "authorization: Bearer $MAIN_JWT_B" \
  --header "Content-Type: application/json";
Example response
{}

Request the handshake with node A

Used variables
# Base URL of node A api
$API_A_BASE

# Node A nodeID
$NODE_ID_A

# Node URI
$NODE_URI

# Node B auth token
$TOKEN_B

# Node B nodeID
$NODE_ID_B
Example request
curl -X POST "$API_A_BASE/federation/nodes/$NODE_ID_A/handshake" \
  --header "Content-Type: application/json" \
  --data "{
    \"nodeURI\": \"$NODE_URI\",
    \"token\": \"$TOKEN_B\",
    \"nodeIDB\": \"$NODE_ID_B\"
  }";
Example response
{}

Confirm the requested handshake

Used variables
# Base URL of node A api
$API_A_BASE

# Node A nodeID
$NODE_ID_A

# Main administrator JWT for node A
$MAIN_JWT_A
Example request
curl -X POST "$API_A_BASE/federation/nodes/$NODE_ID_A/handshake-confirm" \
  -H "authorization: Bearer $MAIN_JWT_A" \
  --header "Content-Type: application/json";
Example response
{}

Complete the handshake

Used variables
# Base URL of node B api
$API_B_BASE

# Node B nodeID
$NODE_ID_B

# Node B auth token
$TOKEN_B

# Node A auth token
$TOKEN_A
Example request
curl -X POST "$API_B_BASE/federation/nodes/$NODE_ID_B/handshake-complete" \
  -H "authorization: Bearer $TOKEN_B" \
  --header "Content-Type: application/json" \
  --data "{
    \"token\": \"$TOKEN_A\"
  }";
Example response
{}

Origin structures

Add module to federation

Used variables
# Base url for the federation api
$BASE_URL

# JWT of the user
$JWT

# Node id of the destination node
$NODE_ID

# Federation module id
$MODULE_ID
Example request
curl -X PUT "$BASE_URL/federation/nodes/$NODE_ID/modules/" \
  -H "Authorization: Bearer $JWT" \
  -H "Content-Type: application/json" \
  --data "{
    \"composeModuleID\": \"$COMPOSE_MODULE_ID\",
    \"composeNamespaceID\": \"$COMPOSE_NAMESPACE_ID\",
    \"name\": \"Account\",
    \"handle\": \"Account\",
    \"fields\": [
        {
            \"kind\": \"String\",
            \"name\": \"AccountName\",
            \"label\": \"Account Name\",
            \"isMulti\": false,
            \"value\": true,
            \"map\": null
        },
        {
            \"kind\": \"User\",
            \"name\": \"OwnerId\",
            \"label\": \"Account Owner\",
            \"isMulti\": false,
            \"value\": true,
            \"map\": null
        }
    ]
}";
Example response
{
    "response": {
        "moduleID": "$MODULE_ID",
        "nodeID": "$NODE_ID",
        "composeModuleID": "$COMPOSE_MODULE_ID",
        "composeNamespaceID": "$COMPOSE_NAMESPACE_ID",
        "handle": "Account",
        "name": "Account",
        "fields": [
            {
                "kind": "String",
                "name": "AccountName",
                "label": "Account Name",
                "isMulti": false
            },
            {
                "kind": "User",
                "name": "OwnerId",
                "label": "Account Owner",
                "isMulti": false
            }
        ],
        "createdAt": "2020-12-01T14:33:14.010034106Z",
        "createdBy": "204158548916043781"
    }
}

Change sharing fields

Used variables
# Base url for the federation api
$BASE_URL

# JWT of the user
$JWT

# Node id of the destination node
$NODE_ID

# Federation module id
$MODULE_ID
Example request
curl -X PUT "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/exposed" \
  -H "Authorization: Bearer $JWT"
  -H "Content-Type: application/json" \
  --data "{
    \"composeModuleID\": \"$COMPOSE_MODULE_ID\",
    \"composeNamespaceID\": \"$COMPOSE_NAMESPACE_ID\",
    \"name\": \"Account\",
    \"handle\": \"Account\",
    \"fields\": [
        {
            \"kind\": \"String\",
            \"name\": \"AccountName\",
            \"label\": \"Account Name\",
            \"isMulti\": false,
            \"value\": true,
            \"map\": null
        },
        {
            \"kind\": \"User\",
            \"name\": \"OwnerId\",
            \"label\": \"Account Owner\",
            \"isMulti\": false,
            \"value\": true,
            \"map\": null
        }
    ]}";
Example response
{
    "response": {
        "moduleID": "$MODULE_ID",
        "nodeID": "$NODE_ID",
        "composeModuleID": "$COMPOSE_MODULE_ID",
        "composeNamespaceID": "$COMPOSE_NAMESPACE_ID",
        "handle": "Account",
        "name": "Account",
        "fields": [
            {
                "kind": "String",
                "name": "AccountName",
                "label": "Account Name",
                "isMulti": false
            },
            {
                "kind": "User",
                "name": "OwnerId",
                "label": "Account Owner",
                "isMulti": false
            }
        ],
        "createdAt": "2020-12-01T14:33:14.010034106Z",
        "createdBy": "204158548916043781",
        "updatedAt": "2020-12-01T14:34:12.972692192Z",
        "updatedBy": "204158548916043781"
    }
}

Info about exposed federated module

Used variables
# Base url for the federation api
$BASE_URL

# JWT of the user
$JWT

# Node id of the destination node
$NODE_ID
Example request
curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/exposed" \
  -H "Authorization: Bearer $JWT";
Example response
{
    "response": {
        "moduleID": "$MODULE_ID",
        "nodeID": "$NODE_ID",
        "composeModuleID": "$COMPOSE_MODULE_ID",
        "composeNamespaceID": "$COMPOSE_NAMESPACE_ID",
        "handle": "Account",
        "name": "Account",
        "fields": [
            {
                "kind": "String",
                "name": "AccountName",
                "label": "Account Name",
                "isMulti": false
            },
            {
                "kind": "User",
                "name": "OwnerId",
                "label": "Account Owner",
                "isMulti": false
            }
        ],
        "createdAt": "2020-12-01T14:33:14.010034106Z",
        "createdBy": "204158548916043781",
        "updatedAt": "2020-12-01T14:34:13Z",
        "updatedBy": "204158548916043781"

    }
}

Remove module from federation

Used variables
# Base url for the federation api
$BASE_URL

# JWT of the user
$JWT

# Node id of the destination node (?exposed) or the origin node (?shared)
$NODE_ID

# Federation module id
$MODULE_ID
Example request
curl -X DELETE "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID" \
  -H "authorization: Bearer $JWT";
Example response
{}

Destination structures

Info about shared federated module

Used variables
# Base url for the federation api
$BASE_URL

# JWT of the user
$JWT

# Node id of the origin node
$NODE_ID
Example request
curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/shared" \
  -H "Authorization: Bearer $JWT";
Example response
{
    "response": {
        "moduleID": "122709113267335170",
        "handle": "Account",
        "name": "Account",
        "createdAt": "2019-12-18T17:45:15Z",
        "updatedAt": "2020-05-26T13:29:36Z",
        "fields": [
            {
                "kind": "Url",
                "name": "LinkedIn",
                "label": "LinkedIn",
                "isMulti": false,
            },
            {
                "kind": "String",
                "name": "Phone",
                "label": "Phone",
                "isMulti": false,
            }
        ]
    }
}

List shared modules

Used variables
# Base url for the federation api
$BASE_URL

# JWT of the user
$JWT

# Node id of the destination node (?exposed) or the origin node (?shared)
$NODE_ID
Example request
curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules" \
  -H "Authorization: Bearer $JWT";
Example response
{
    "response": {
        "filter": {
            "query": "",
            "handle": "",
            "name": "",
            "sort": "name ASC",
            "count": 1
        },
        "set": [
            {
                "moduleID": "122709113267335170",
                "handle": "Account",
                "name": "Account",
                "createdAt": "2019-12-18T17:45:15Z",
                "updatedAt": "2020-05-26T13:29:36Z",
                "fields": [
                    {
                        "kind": "Url",
                        "name": "LinkedIn",
                        "label": "LinkedIn",
                        "isMulti": false,
                    },
                    {
                        "kind": "String",
                        "name": "Phone",
                        "label": "Phone",
                        "isMulti": false,
                    }
                ]
            }
        ]
    }
}

Set module mapping for a module

Used variables
# Base url for the federation api
$BASE_URL

# JWT of the user
$JWT

# Node id of the destination node
$NODE_ID

# Federation module id
$MODULE_ID
Example request
curl -X PUT "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/mapped" \
  -H "Authorization: Bearer $JWT"
  -H "Content-Type: application/json" \
  --data "[{
      \"origin\":{
          \"name\":\"LinkedIn\",
          \"kind\":\"Url\",
          \"is_multi\":0
        },
        \"destination\":{
            \"name\":\"Social\",
            \"kind\":\"String\",
            \"is_multi\":0
        }
    }]";
Example response
{
    "response": {
        "moduleID": "122709113267335170",
        "handle": "Account",
        "name": "Account",
        "createdAt": "2019-12-18T17:45:15Z",
        "updatedAt": "2020-05-26T13:29:36Z",
        "mapping": [
            {
                "origin": {
                    "name": "LinkedIn",
                    "kind": "Url",
                    "is_multi": 0
                },
                "destination": {
                    "name": "Social",
                    "kind": "String",
                    "is_multi": 0
                }
            }
        ]
    }
}

Get module mapping for a module

Used variables
# Base url for the federation api
$BASE_URL

# JWT of the user
$JWT

# Node id of the destination node
$NODE_ID

# Federation module id
$MODULE_ID
Example request
curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/mapped" \
  -H "Authorization: Bearer $JWT";
Example response
{
    "response": {
        "moduleID": "122709113267335170",
        "handle": "Account",
        "name": "Account",
        "createdAt": "2019-12-18T17:45:15Z",
        "updatedAt": "2020-05-26T13:29:36Z",
        "mapping": [
            {
                "origin": {
                    "name": "LinkedIn",
                    "kind": "Url",
                    "is_multi": 0
                },
                "destination": {
                    "name": "Social",
                    "kind": "String",
                    "is_multi": 0
                }
            }
        ]
    }
}

Remove module mapping from federation

Used variables
# Base url for the federation api
$BASE_URL

# JWT of the user
$JWT

# Node id of the destination node (?exposed) or the origin node (?shared)
$NODE_ID

# Federation module id
$MODULE_ID
Example request
curl -X DELETE "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID" \
  -H "authorization: Bearer $JWT";
Example response

Structure sync

Get origin changes

$TOKEN_B is the token that was generated during the handshake and is used to authenticate the user on the Origin node (the one who shares the data) by the Destination node.
Used variables
# Base url for the federation api
$BASE_URL

# JWT of the user
$JWT

# Node id of the destination node
$NODE_ID

# Node B auth token
$TOKEN_B
Example request
curl -X GET "$BASE_URL/federation/exposed/modules" \
  -H "Authorization: Bearer $TOKEN_B";
Example response
{
    "response": {
        "filter": {
            "query": "after=1600109447",
            "page": 1,
            "perPage": 20,
            "count": 97,
        },
        "set": [
            {
                "type": "GET",
                "rel": "Account",
                "href": "$BASE_URL/federation/exposed/modules/$MODULE_ID?after=1600109447"
            },
            {
                "type": "GET",
                "rel": "Contact",
                "href": "$BASE_URL/federation/exposed/modules/$MODULE_ID?after=1600109447"
            }
        ]
    }
}

Sync shared module structure

$TOKEN_B is the token that was generated during the handshake and is used to authenticate the user on the Origin node (the one who shares the data) by the Destination node.
Used variables
# Base url for the federation api
$BASE_URL

# JWT of the user
$JWT

# Node id of the origin node
$NODE_ID

# Node B auth token
$TOKEN_B
Example request
curl -X GET "$BASE_URL/federation/exposed/modules/$MODULE_ID" \
  -H "Authorization: Bearer $TOKEN_B";
Example response
{
    "response": {
        "moduleID": "122709113267335170",
        "handle": "Account",
        "name": "Account",
        "createdAt": "2019-12-18T17:45:15Z",
        "updatedAt": "2020-05-26T13:29:36Z",
        "fields": [
            {
                "kind": "Url",
                "name": "LinkedIn",
                "label": "LinkedIn",
                "isMulti": false,
            },
            {
                "kind": "String",
                "name": "Phone",
                "label": "Phone",
                "isMulti": false,
            }
        ]
    }
}

Fetch exposed data

$TOKEN_B is the token that was generated during the handshake and is used to authenticate the user on the Origin node (the one who shares the data) by the Destination node.

Used variables
# Base url for the federation api
$BASE_URL

# JWT of the user
$JWT

# Node id of the destination node (?exposed) or the origin node (?shared)
$NODE_ID

# Federation module id
$MODULE_ID

# Node B auth token
$TOKEN_B
Example request
curl -X GET "$BASE_URL/federation/nodes/$NODE_ID/modules/$MODULE_ID/records?lastSync=$AFTER_TIMESTAMP" \
  -H "Authorization: Bearer $TOKEN_B";
Example response
{
    "response": {
        "filter": {
            "moduleID": "132954639472525355",
            "query": "",
            "sort": "createdAt DESC",
            "page": 1,
            "perPage": 20,
            "count": 97,
            "deleted": 0
        },
        "set": [
            {
                "recordID": "$COMPOSE_RECORD_ID",
                "moduleID": "$FEDERATION_MODULE_ID",
                "values": [
                    {
                        "name": "name",
                        "value": "John"
                    },
                    {
                        "name": "surname",
                        "value": "Doe"
                    }
                ],
                "createdAt": "2020-09-08T19:56:14Z",
                "updatedAt": "2020-09-09T18:05:33Z"
            }
        ]
    }
}