This page applies to Apigee and Apigee hybrid.
You can create a dependency between APIs, API versions, and API operations in API hub. The high-level process to create a dependency is as follows:
- Find two APIs that may have operations that may be dependent. The operations may be in registered APIs or external APIs.
 - Determine which API is the supplier and which is the consumer. As discussed previously, the consumer invokes the supplier.
 - Use the Google Cloud console or the Create dependency API to create the dependency between the supplier and consumer.
 
Create a dependency
You can create a dependency in the console or with the REST API.
Console
To create a dependency using the Google Cloud console, do the following:
In the Google Cloud console, go to the API supply chain page in API hub.
Go to API hub- Click Create dependency and provide the following inputs in the Create a new dependency page.
 - Under General details, do the following:
          
- Specify unique ID: (Optional) The identifier of the dependency. If not provided, a system-generated ID will be used.
 - Description: (Optional) A brief description of the dependency.
 - Click Continue.
 
 - Under Select supplier resource, do the following:
          
- Resource type: Select Operation as the supplier resource type.
 - Supplier API: Select the API that supplies the operation.
 - Version: Select the API version of the supplier API that provides the operation.
 - Operation: Select the operation that is supplied to the consumer. For example: 
GET-/items. - Click Continue.
 
 - Under Select consumer resource, do the following:
          
- Resource type: Select Operation as the consumer resource type.
 - Consumer API: Select the API that consumes the operation.
 - Version: Select the API version of the consumer API that consumes the operation.
 - Operation: Select the operation that is consumed by the supplier. For example: 
GET-/categories. - Click Continue.
 
 - Optionally, provide values for any user-defined attributes that were defined in Settings.
 - Click Create. The new dependency appears in the API supply chain page.
 
REST API
To create a new dependency using the Create a dependency API, use the following command:
  curl -X POST 'https://apihub.googleapis.com/v1/projects/HUB_PROJECT/locations/HUB_LOCATION/dependencies?dependency_id=DEPENDENCY_ID' \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H 'Content-Type: application/json' \
  --d '{
      "description": "DESCRIPTION",
      "supplier": {
          // Specify one of the following:
          "operation_resource_name": RESOURCE_NAME
          // OR
          "external_api_resource_name: RESOURCE_NAME"
      },
      "consumer": {
        // Specify one of the following:
        "operation_resource_name": RESOURCE_NAME
        // OR
        "external_api_resource_name: RESOURCE_NAME"
      }
  }'
Replace the following:
- HUB_PROJECT: The name of your API hub host project. The host project was selected when API hub was provisioned.
 - HUB_LOCATION: The location of the host project. The location was chosen when API hub was provisioned.
 - DEPENDENCY_ID: (Optional) The identifier of the dependency. If not provided, a system-generated ID will be used.
 - DESCRIPTION: (Optional) A brief description of the dependency.
 RESOURCE_NAME: (Required) Either the resource name of an operation in API hub or an external API, depending on which attribute you specify.
Operation resource names follow this format:
projects/PROJECT/locations/LOCATION/apis/API/versions/VERSION/operations/OPERATIONOperation resource example:
"projects/myproject/locations/us-central1/apis/payments-api/versions/locationv1/operations/getlocation".External API resource names follow this format:
projects/PROJECT/locations/LOCATION/externalApis/EXTERNAL_APIExternal API resource example:
"projects/myproject/locations/us-central1/externalApis/petstore".
Example:
  curl -X POST 'https://apihub.googleapis.com/v1/projects/myproject/locations/us-central1/dependencies?dependency_id=user-to-pet' \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H 'Content-Type: application/json' \
  --d '{
      "description": "Dependency from user to pet API",
      "consumer": {
          "operation_resource_name": "projects/myproject/locations/us-central1/apis/payments-api/versions/paymentv1/operations/createuser"
      },
      "supplier": {
          "operation_resource_name": "projects/myproject/locations/us-central1/apis/pet-api/versions/petstorev1/operations/addpet"
      }
  }'
Sample response:
{
  "name": "projects/myproject/locations/us-central1/dependencies/user-to-pet",
  "consumer": {
      "displayName": "POST - /v2/user",
      "operationResourceName": "projects/myproject/locations/us-central1/apis/payments-api/versions/version1/operations/createuser"
  },
  "supplier": {
      "displayName": "POST - /v2/pet",
      "operationResourceName": "projects/myproject/locations/us-central1/apis/payments-api/versions/version1/operations/addpet"
  },
  "state": "VALIDATED",
  "description": "Dependency from user to pet API",
  "discoveryMode": "MANUAL",
  "createTime": "2024-04-17T19:33:31.664226Z",
  "updateTime": "2024-04-17T19:33:31.664226Z"
 }What's next?
- Learn about how to manage dependencies.