> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreflux.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Sap Ariba Open Api

> Client-mode REST API connectors for SAP Ariba: purchase orders and line items on SAP Business Network for suppliers and buyers, supplier catalog items, Operational Reporting for Procurement, and Document Approval for requisitions and invoices

Technical Preview

## Overview

Client-mode REST API connectors for SAP Ariba: purchase orders and line items on SAP Business Network for suppliers and buyers, supplier catalog items, Operational Reporting for Procurement, and Document Approval for requisitions and invoices.

This is one of the templates in the SAP Ariba REST API app (`sap-ariba`). Deploy it alongside the other connectors of that app when they depend on each other (for example a token connector plus an API connector).

> [!NOTE]
>
> Not yet verified against the live vendor API: No SAP Ariba Developer Portal application (OAuth client + application key) or realm / ANID. All 16 gateway events were sent to openapi.ariba.com with dummy credentials and got 401 Unauthorized (an unknown service answers 403), and the OAuth server answered 401 for a dummy client, but no authenticated call could run.

## Auth

* **schemes**: \["OAuth 2.0 client credentials at /v2/oauth/token with Basic base64(clientId:clientSecret)", "apiKey header (application key) + Authorization: Bearer \<access\_token> on every gateway call", "X-ARIBA-NETWORK-ID header (ANID) on SAP Business Network APIs", "realm query parameter on realm APIs"]
* **secrets**: \["ARIBA\_OAUTH\_BASIC", "ARIBA\_API\_KEY", "ARIBA\_ANID"]
* **note**: One Developer Portal application per API; key and token must come from the same application.

Auth headers used by the template: `Authorization: Bearer {value.json.token}`, `apiKey: {value.json.apikey}`.

## Template parameters

| Placeholder | Type | Description | Required |
| - | - | - | - |
| `RouteName` | string | Name of the Sap Ariba Open Api connector | no |
| `BaseUrl` | string | Sap Ariba Open Api base URL without trailing slash (e.g. [https://openapi.ariba.com](https://openapi.ariba.com)) | yes |

`BASE_ADDRESS` default: `https://openapi.ariba.com`.

## Events

| Event | Method | Endpoint | Request topic | Response topic | Payload fields |
| - | - | - | - | - | - |
| `SupplierOrders` | GET | `/api/purchase-orders-supplier/v1/prod/orders?{value.json.query}` | `erp/sap-ariba/supplier/orders/get` | `erp/sap-ariba/supplier/orders/get/response` | `anid`, `apikey`, `query`, `token` |
| `SupplierOrderItems` | GET | `/api/purchase-orders-supplier/v1/prod/items?{value.json.query}` | `erp/sap-ariba/supplier/order-items/get` | `erp/sap-ariba/supplier/order-items/get/response` | `anid`, `apikey`, `query`, `token` |
| `BuyerOrders` | GET | `/api/purchase-orders/v1/prod/orders?{value.json.query}` | `erp/sap-ariba/buyer/orders/get` | `erp/sap-ariba/buyer/orders/get/response` | `anid`, `apikey`, `query`, `token` |
| `BuyerOrderItems` | GET | `/api/purchase-orders/v1/prod/items?{value.json.query}` | `erp/sap-ariba/buyer/order-items/get` | `erp/sap-ariba/buyer/order-items/get/response` | `anid`, `apikey`, `query`, `token` |
| `CatalogSubscriptions` | GET | `/api/catalogcontent/v1/prod/catalogs?realm={value.json.realm}&date={value.json.date}{value.json.params}` | `erp/sap-ariba/catalog/subscriptions/get` | `erp/sap-ariba/catalog/subscriptions/get/response` | `apikey`, `date`, `params`, `realm`, `token` |
| `CatalogItems` | GET | `/api/catalogcontent/v1/prod/catalogname/{value.json.catalogname}/supplierid/{value.json.supplierid}/items?realm={value.json.realm}{value.json.params}` | `erp/sap-ariba/catalog/items/get` | `erp/sap-ariba/catalog/items/get/response` | `apikey`, `catalogname`, `params`, `realm`, `supplierid`, `token` |
| `CatalogItemSchema` | GET | `/api/catalogcontent/v1/prod/items/schema?realm={value.json.realm}` | `erp/sap-ariba/catalog/items/schema/get` | `erp/sap-ariba/catalog/items/schema/get/response` | `apikey`, `realm`, `token` |
| `ReportingViewTemplates` | GET | `/api/procurement-reporting-view/v2/prod/viewTemplates?realm={value.json.realm}{value.json.params}` | `erp/sap-ariba/reporting/view-templates/get` | `erp/sap-ariba/reporting/view-templates/get/response` | `apikey`, `params`, `realm`, `token` |
| `ReportingView` | GET | `/api/procurement-reporting-details/v2/prod/views/{value.json.template}?realm={value.json.realm}{value.json.params}` | `erp/sap-ariba/reporting/view/get` | `erp/sap-ariba/reporting/view/get/response` | `apikey`, `params`, `realm`, `template`, `token` |
| `ReportingViewCount` | GET | `/api/procurement-reporting-details/v2/prod/views/{value.json.template}/count?realm={value.json.realm}{value.json.params}` | `erp/sap-ariba/reporting/view/count` | `erp/sap-ariba/reporting/view/count/response` | `apikey`, `params`, `realm`, `template`, `token` |
| `ReportingJobSubmit` | POST | `/api/procurement-reporting-job/v2/prod/jobs?realm={value.json.realm}` | `erp/sap-ariba/reporting/jobs/submit` | `erp/sap-ariba/reporting/jobs/submit/response` | `apikey`, `body`, `realm`, `token` |
| `ReportingJobStatus` | GET | `/api/procurement-reporting-jobresult/v2/prod/jobs/{value.json.jobid}?realm={value.json.realm}` | `erp/sap-ariba/reporting/jobs/status/get` | `erp/sap-ariba/reporting/jobs/status/get/response` | `apikey`, `jobid`, `realm`, `token` |
| `ApprovalChanges` | GET | `/api/approval/v1/prod/changes?realm={value.json.realm}{value.json.params}` | `erp/sap-ariba/approval/changes/get` | `erp/sap-ariba/approval/changes/get/response` | `apikey`, `params`, `realm`, `token` |
| `PendingApprovables` | GET | `/api/approval/v1/prod/pendingApprovables?realm={value.json.realm}{value.json.params}` | `erp/sap-ariba/approval/pending/get` | `erp/sap-ariba/approval/pending/get/response` | `apikey`, `params`, `realm`, `token` |
| `GetApprovable` | GET | `/api/approval/v1/prod/{value.json.approvabletype}/{value.json.approvableid}?realm={value.json.realm}` | `erp/sap-ariba/approval/approvable/get` | `erp/sap-ariba/approval/approvable/get/response` | `apikey`, `approvableid`, `approvabletype`, `realm`, `token` |
| `SetApprovableState` | PATCH | `/api/approval/v1/prod/{value.json.approvabletype}/{value.json.approvableid}?realm={value.json.realm}&user={value.json.user}&passwordadapter={value.json.passwordadapter}` | `erp/sap-ariba/approval/approvable/set` | `erp/sap-ariba/approval/approvable/set/response` | `apikey`, `approvableid`, `approvabletype`, `body`, `passwordadapter`, `realm`, `token`, `user` |

## Deploy

Get the template card (JSON with `template` and `metadata`) from the broker, then deploy the connector:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_pub -t '$SYS/Coreflux/Command' -m "-routeCode SAP_ARIBA"
```

The deployable connector from the REST API app, with `BASE_ADDRESS` already filled in:

```lot theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
DEFINE ROUTE SapAribaOpenApi WITH TYPE REST_API
    ADD REST_API_CONFIG
        WITH BASE_ADDRESS "https://openapi.ariba.com"
        WITH ENABLE_CLIENT "true"
        WITH USE_SSL "true"
        WITH REQUEST_TIMEOUT '60'
        WITH DEFAULT_CONTENT_TYPE "application/json"
    ADD EVENT SupplierOrders
        WITH SOURCE_TOPIC "erp/sap-ariba/supplier/orders/get"
        WITH DESTINATION_TOPIC "erp/sap-ariba/supplier/orders/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/purchase-orders-supplier/v1/prod/orders?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
            ADD "X-ARIBA-NETWORK-ID" "{value.json.anid}"
    ADD EVENT SupplierOrderItems
        WITH SOURCE_TOPIC "erp/sap-ariba/supplier/order-items/get"
        WITH DESTINATION_TOPIC "erp/sap-ariba/supplier/order-items/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/purchase-orders-supplier/v1/prod/items?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
            ADD "X-ARIBA-NETWORK-ID" "{value.json.anid}"
    ADD EVENT BuyerOrders
        WITH SOURCE_TOPIC "erp/sap-ariba/buyer/orders/get"
        WITH DESTINATION_TOPIC "erp/sap-ariba/buyer/orders/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/purchase-orders/v1/prod/orders?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
            ADD "X-ARIBA-NETWORK-ID" "{value.json.anid}"
    ADD EVENT BuyerOrderItems
        WITH SOURCE_TOPIC "erp/sap-ariba/buyer/order-items/get"
        WITH DESTINATION_TOPIC "erp/sap-ariba/buyer/order-items/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/purchase-orders/v1/prod/items?{value.json.query}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
            ADD "X-ARIBA-NETWORK-ID" "{value.json.anid}"
    ADD EVENT CatalogSubscriptions
        WITH SOURCE_TOPIC "erp/sap-ariba/catalog/subscriptions/get"
        WITH DESTINATION_TOPIC "erp/sap-ariba/catalog/subscriptions/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/catalogcontent/v1/prod/catalogs?realm={value.json.realm}&date={value.json.date}{value.json.params}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT CatalogItems
        WITH SOURCE_TOPIC "erp/sap-ariba/catalog/items/get"
        WITH DESTINATION_TOPIC "erp/sap-ariba/catalog/items/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/catalogcontent/v1/prod/catalogname/{value.json.catalogname}/supplierid/{value.json.supplierid}/items?realm={value.json.realm}{value.json.params}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT CatalogItemSchema
        WITH SOURCE_TOPIC "erp/sap-ariba/catalog/items/schema/get"
        WITH DESTINATION_TOPIC "erp/sap-ariba/catalog/items/schema/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/catalogcontent/v1/prod/items/schema?realm={value.json.realm}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT ReportingViewTemplates
        WITH SOURCE_TOPIC "erp/sap-ariba/reporting/view-templates/get"
        WITH DESTINATION_TOPIC "erp/sap-ariba/reporting/view-templates/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/procurement-reporting-view/v2/prod/viewTemplates?realm={value.json.realm}{value.json.params}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT ReportingView
        WITH SOURCE_TOPIC "erp/sap-ariba/reporting/view/get"
        WITH DESTINATION_TOPIC "erp/sap-ariba/reporting/view/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/procurement-reporting-details/v2/prod/views/{value.json.template}?realm={value.json.realm}{value.json.params}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT ReportingViewCount
        WITH SOURCE_TOPIC "erp/sap-ariba/reporting/view/count"
        WITH DESTINATION_TOPIC "erp/sap-ariba/reporting/view/count/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/procurement-reporting-details/v2/prod/views/{value.json.template}/count?realm={value.json.realm}{value.json.params}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT ReportingJobSubmit
        WITH SOURCE_TOPIC "erp/sap-ariba/reporting/jobs/submit"
        WITH DESTINATION_TOPIC "erp/sap-ariba/reporting/jobs/submit/response"
        WITH METHOD "POST"
        WITH ENDPOINT "/api/procurement-reporting-job/v2/prod/jobs?realm={value.json.realm}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
    ADD EVENT ReportingJobStatus
        WITH SOURCE_TOPIC "erp/sap-ariba/reporting/jobs/status/get"
        WITH DESTINATION_TOPIC "erp/sap-ariba/reporting/jobs/status/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/procurement-reporting-jobresult/v2/prod/jobs/{value.json.jobid}?realm={value.json.realm}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT ApprovalChanges
        WITH SOURCE_TOPIC "erp/sap-ariba/approval/changes/get"
        WITH DESTINATION_TOPIC "erp/sap-ariba/approval/changes/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/approval/v1/prod/changes?realm={value.json.realm}{value.json.params}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT PendingApprovables
        WITH SOURCE_TOPIC "erp/sap-ariba/approval/pending/get"
        WITH DESTINATION_TOPIC "erp/sap-ariba/approval/pending/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/approval/v1/prod/pendingApprovables?realm={value.json.realm}{value.json.params}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT GetApprovable
        WITH SOURCE_TOPIC "erp/sap-ariba/approval/approvable/get"
        WITH DESTINATION_TOPIC "erp/sap-ariba/approval/approvable/get/response"
        WITH METHOD "GET"
        WITH ENDPOINT "/api/approval/v1/prod/{value.json.approvabletype}/{value.json.approvableid}?realm={value.json.realm}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
    ADD EVENT SetApprovableState
        WITH SOURCE_TOPIC "erp/sap-ariba/approval/approvable/set"
        WITH DESTINATION_TOPIC "erp/sap-ariba/approval/approvable/set/response"
        WITH METHOD "PATCH"
        WITH ENDPOINT "/api/approval/v1/prod/{value.json.approvabletype}/{value.json.approvableid}?realm={value.json.realm}&user={value.json.user}&passwordadapter={value.json.passwordadapter}"
        WITH HEADERS
            ADD "Accept" "application/json"
            ADD "User-Agent" "Coreflux-Broker REST_API route (https://www.coreflux.org)"
            ADD "apiKey" "{value.json.apikey}"
            ADD "Authorization" "Bearer {value.json.token}"
            ADD "Content-Type" "application/json"
        WITH BODY "{value.json.body}"
```

Deploy it with `-addRoute` (do not include `ADD METADATA`).

## Usage example

Call `SupplierOrders` by publishing a JSON payload to its request topic, and read the reply on the response topic:

```bash theme={"theme":"css-variables","languages":{"custom":["/languages/lot.json"]}}
mosquitto_sub -t 'erp/sap-ariba/supplier/orders/get/response' &
mosquitto_pub -t 'erp/sap-ariba/supplier/orders/get' -m '{"anid": "<anid>", "apikey": "<apikey>", "query": "<query>", "token": "<token>"}'
```

## Related

* [REST API Connectors](/latest/lot-language/routes/rest-api-routes)
* [REST API Apps catalog](/latest/lot-language/routes/rest-api-apps)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.