Managing resources

This pageapplies toApigee andApigee hybrid.

View Apigee Edge documentation.

Note: In environments enabled forarchive deployments, you cannot manage resources using the Apigee UI, API, or gcloud. To manage resources for archive deployments using Apigee in VS Code,seeManaging resources.

Understand and manage resources, as described in the following sections.

About resources

Many policy types rely onresources. Resources are the files that implement the code or configuration to be executed by a policy when attached to an API proxy. In some cases, as with JavaScript and JavaCallout, a policy simply defines an attachment point in an API proxy where some code should execute. The JavaScript or JavaCallout policy is a pointer to a resource.

Resource types

The following table summarizes the resource types:

Resource typeDescription
GraphQL (graphql)GraphQL schema file referenced byGraphQL policies.
JAR (java)Java classes in a JAR file referenced byJavaCallout policies.
JavaScript (js)JavaScript referenced byJavaScript policies.
JavaScript (jsc)Compiled JavaScript referenced byJavaScript policies.
OpenAPI Specification (oas)OpenAPI Specification used to validate request and response messages of type JSON or YAML.
Property Set (properties)Collection of key/value pairs that can be referenced an API proxyproperty sets.
Python (py)Python scripts referenced byPythonScript policies. Resources must be implemented in "pure Python" (in the Python language only).
Security policy (securityPolicy)Custom security policy referenced byJavaCallout policies.
WSDL (wsdl)WSDL files referenced bySOAPMessageValidation policies.
XSD (xsd)XML schemas referenced bySOAPMessageValidation policies.
XSL Transformations (xsl)XSLT transformations referenced byXSLTransform policies.

Where resources are stored

You can store resources to the following locations. You can't store resource files in anorganization.

The environment repository is available at the following URI, as described by theList resource files API and later inManage resources using the API:/organizations/$ORG/environments/$ENV/resourcefiles

Note: You cannot view the API proxy revision resource repository using the API.

The following table shows the methods you can use to create, update,and delete resources for each repository:

RepositoryCreateViewUpdateDelete
APIUIAPIUIAPIUIAPIUI
API proxy revision
Environment

For example, all JavaScript files available to thetest environment are stored inthe following repository and are available to any API proxy running in thetest environment:

/organizations/$ORG/environments/test/resourcefiles/jsc

Resource name resolution

Resolve resource names from the most specific to the most general scope. Resource names are resolved "up the chain", from the API proxy revision level, to the environment level.

Let's say that you have populated the same resource in two different repositories — the API proxy revision and theprod environment.

Consider the API proxy that is configured with the following policy:

<Javascript name='PathSetterPolicy' timeLimit='200'>    <ResourceURL>jsc://pathSetter.js</ResourceURL></Javascript>

The policy reference cannot explicitly resolve to a repository. The first resource at the most granular scope whose name matches the resource name in the policy is resolved.

So, when the API proxy is deployed in the environmentprod, the policy will resolve to the environment-scopedpathSetter.js resource.

When deployed in the environmenttest, the Policy will resolve to theAPI proxy revision-scoped resource, because the environment-scoped resource is in theprodenvironment, not thetest environment.

Java resource guidelines

You can add compiled Java resources as JAR files using multiple options in curl, such as-T,--data-binary, or-F option (not the-d option). For example:

curl"http://apigee.googleapis.com/v1/organizations/$ORG/environments/$ENV/resourcefiles?name={jar_file}&type=java"\-XPOST\-H"Authorization: Bearer $TOKEN"\-H"Content-Type: application/octet-stream"\--data-binary@{jar_file}
curl"http://apigee.googleapis.com/v1/organizations/$ORG/environments/$ENV/resourcefiles?name={jar_file}&type=java"\-XPOST\-H"Authorization: Bearer $TOKEN"\-H"Content-Type: application/octet-stream"\-T"{jar_file}"
curl"http://apigee.googleapis.com/v1/organizations/$ORG/environments/$ENV/resourcefiles?name={jar_file}&type=java"\-XPOST\-H"Authorization: Bearer $TOKEN"\-H"Content-Type: application/octet-stream"\-F"file=@{jar_file}"
Note:Package naming: Don't useio.apigee orcom.apigee as package names in JavaCallout policies. Those are reserved and used by other Apigee modules.

See also:

Manage resources using the UI

Manage resources scoped to anAPI proxy revision using the UI, as described in the following sections.

Note: You cannot manage resources that are scoped to anorganization orenvironment using the UI; instead, you must use theAPI.

View resources using the UI

Apigee in Cloud console

  1. In the Google Cloud console, go to theProxy development> API proxies page.

    Go to API proxies

  2. Select the API proxy whose resources you want to view. This displays the Proxy EditorOverview view.

  3. Click theDevelop tab.
  4. In the navigation pane, scroll down toResources. The current resources are displayed below that.

Classic UI

To view the resources scoped to an API proxy revision using the classic Proxy Editor:

  1. Sign in to theApigee UI.
  2. SelectDevelop > API Proxies in the left navigation bar.
  3. Select an API proxy in the list for which you want to create a resource.
    The API proxy editor opens and theOverview tab is displayed, by default.
  4. Click theDevelop tab.
  5. Select the revision in theRevision drop-down, if required.

    The resources scoped to the API proxy revision are listed in theResources section in the Navigator view.

Create a resource using the UI

Apigee in Cloud console

To create a resource using the Apigee in Cloud console :

  1. In the Google Cloud console, go to theProxy development> API proxies page.

    Go to API proxies

  2. Select the API proxy whose resources you want to view. This displays the Proxy EditorOverview view.

  3. Click theDevelop tab.
  4. In the navigation pane, scroll down toResources and click the+ button to its right.
  5. In theAdd resource dialog, enter the following:
    • Resource type: Select the type of file for the resource.
    • UnderSource, select eitherCreate a new file orImport file. If you chooseImport file, also select a file to import in theFile field.
    • Resource name: Enter a name for the resource.
  6. ClickAdd.

Classic Apigee

To create resources scoped to an API proxy revision using the classic Apigee UI:

  1. View the resources scoped to the API proxy revision.
  2. Click+ in the Resources section in the Navigator view to open the New Resource dialog.
  3. Enter the following:
    FieldDescription
    SourceSelect to create a new file or import a file.
    File TypeSelect aresource type from the drop-down list.
    File NameName of the file. The filename extension must be valid for the selected file type.

Update a resource using the UI

Update a resource scoped to an API proxy revisiononly if the revision has not been deployed. After an API proxy revision is deployed, it is immutable.

To update a resource scoped to an API proxy revision using the UI:

  1. View the resources scoped to the API proxy revision.
  2. In the Navigator view underResources, click the resource that you want to update.
    Note: For JAR files, position your cursor over the resource that you want to edit and clickImage of the edit icon..
  3. Update the resource, as required.
    Note: After uploading a new JAR file, clickUpdate.

Delete a resource using the UI

Delete a resource scoped to an API proxy revisiononly if the revision has not been deployed. After an API proxy revision is deployed, it is immutable.

To delete a resource scoped to an API proxy revision using the UI:

  1. View the resources scoped to the API proxy revision.
  2. In the Navigator view under Resources, position your cursor over the resource that you want to delete to display the actions menu.
  3. ClickImage of the delete icon..
  4. ClickDelete to confirm the action.

Manage resources using the API

Manage resources using the API, as described in the following sections.

Create resources using the API

Create resources that are scoped to anAPI proxy revision orenvironment, as described in the following sections.

Create resources scoped to an API proxy revision using the API

Create resources that are scoped to an API proxy revision using the API, as described in the following sections.Note: You can create a resource that is scoped to an existing API proxy revisiononly if the revision has not been deployed. After an API proxy revision is deployed, it is immutable.

To create a resource that is scoped to an API proxy revision using the API:

  1. Create the resource file.
  2. Add the resource file to anAPI proxy configuration bundle.
  3. Upload the bundle using one of the following APIs:

Create resources scoped to an environment using the API

Create resources that are scoped to an environment using the API by issuing aPOST request to the following resource:/organizations/$ORG/environments/$ENV/resourcefiles

Pass the following information with your request:

  • Set thename query parameter to the name of the resource
  • Set thetype query parameter to the requiredresource type
  • Pass the contents of the resource file asapplication/octet-stream ormultipart/form-data)
Note: When importing a resource file using the API, you might need tochmod the file's permissions so that your development tool (suchascurl) can upload it.

The following example shows how to create a JavaScript resource by passing its contents in the request body.

curl -X POST https://apigee.googleapis.com/v1/organizations/myorg/environments/test/resourcefiles?name=pathSetter.js&type=jsc  -H "Authorization: Bearer $TOKEN" \  -H "Content-type:application/octet-stream" \  -d 'request.headers["RequestPath"] = context.getVariable("proxy.basepath");'

Where$TOKEN is set to your OAuth 2.0 access token, as described inObtaining an OAuth 2.0 access token. For information about thecurl options used in this example, seeUsing curl. For a description of environment variables you can use, seeSettingenvironment variables for Apigee API requests.

The following example shows how to upload the resource as a file from your local machine. It's important to use-F for the binary upload in curl in order for the environment- or organization-scoped JavaScript files to be accessible by the JavaScript policy.

curl -X POST https://apigee.googleapis.com/v1/organizations/myorg/environments/test/resourcefiles?name=pathSetter.js&type=jsc  -H "Authorization: Bearer $TOKEN" \  -H "Content-type:multipart/form-data" \  -F file=@pathSetter.js

The following provides an example of the response:

{"name":"pathSetter.js","type":"jsc"}
Note: When using a REST client, such as Postman:
  • Set theContent-Type tomultipart/form-data.
  • Attach the script as a file.

View resources using the API

The following sections describe how to view resources using the API.

View all resources using the API

View all resources scoped to an environment using the API, as described in the following sections.

Using the API you can view resources scoped to an environment only.

To view all resources in an environment using the API, issue aGET request to the following resource:https://apigee.googleapis.com/v1/organizations/$ORG/environments/$ENV/resourcefiles

The following example lists all resources in thetest environment:

curl -X GET https://apigee.googleapis.com/v1/organizations/myorg/environments/test/resourcefiles  -H "Authorization: Bearer $TOKEN"

Where$TOKEN is set to your OAuth 2.0 access token, as described inObtaining an OAuth 2.0 access token. For information about thecurl options used in this example, seeUsing curl. For a description of environment variables you can use, seeSettingenvironment variables for Apigee API requests.

For more information, seeList environment resource files API.

The following provides an example of the response.

{  "resourceFile": [{  "name" : "pathSetter.js",  "type" : "jsc"}  ]}

View the contents of a resource using the API

To view the contents of a resource in an environment using the API, issue aGET request to the following resource:/organizations/$ORG/environments/$ENV/resourcefiles/$TYPE/$NAME

The following example lists the contents of thepathSetter.js JavaScript (jsc) file in thetest environment:

curl -X GET https://apigee.googleapis.com/v1/organizations/myorg/environments/test/resourcefiles/jsc/pathSetter.js  -H "Authorization: Bearer $TOKEN"

Where$TOKEN is set to your OAuth 2.0 access token, as described inObtaining an OAuth 2.0 access token. For information about thecurl options used in this example, seeUsing curl. For a description of environment variables you can use, seeSettingenvironment variables for Apigee API requests.

The following provides an example of the response:

request.headers["RequestPath"] = context.getVariable("proxy.basepath");

Update resources using the API

Update resources that are scoped to anAPI proxy revision orenvironment, as described in the following sections.

Update resources scoped to an API proxy revision using the API

Note: You can update a resource that is scoped to an existing API proxy revisiononly if the revision has not been deployed. After an API proxy revision is deployed, it is immutable.

To update a resource that is scoped to an API proxy revision using the API:

  1. Download the API proxy configuration bundle using theGet API proxy revision API with the following options:
    • Set theformat query parameter tobundle
    • Set theAccept header toapplication/zip
  2. Update the resource file in theAPI proxy configuration bundle.
  3. Upload the API proxy configuration bundle using theUpdate API proxy revision API.

Update resources scoped to an environment using the API

Update a resource that is scoped to to an environment using the API by issuing aPUT request to the following resource:/organizations/$ORG/environments/$ENV/resourcefiles/$TYPE/$NAME

Pass the contents of the resource file asapplication/octet-stream ormultipart/form-data.

Note: When importing a resource file using the API, you might need tochmod the file's permissions so that your development tool (suchascurl) can upload it.

The following example shows how to update a JavaScript resource by passing its contents in the request body.

curl -X PUT https://apigee.googleapis.com/v1/organizations/myorg/environments/test/resourcefiles/jsc/pathSetter.js  -H "Authorization: Bearer $TOKEN" \  -H "Content-type:application/octet-stream" \  -d 'request.headers["RequestPath"] = context.getVariable("proxy.basepath");'

Where$TOKEN is set to your OAuth 2.0 access token, as described inObtaining an OAuth 2.0 access token. For information about thecurl options used in this example, seeUsing curl. For a description of environment variables you can use, seeSettingenvironment variables for Apigee API requests.

The following example shows how to update the resource file using a file from your local machine. It's important to use-F for the binary upload in curl in order for the environment- or organization-scoped JavaScript files to be accessible by the JavaScript policy.

curl -X PUT https://apigee.googleapis.com/v1/organizations/myorg/environments/test/resourcefiles/jsc/pathSetter.js  -H "Authorization: Bearer $TOKEN" \  -H "Content-type:multipart/form-data" \  -F file=@pathSetter.js

The following provides an example of the response:

{"name":"pathSetter.js","type":"jsc"}

Delete resources using the API

Delete resource scoped to anAPI proxy revision orenvironment, as described in the following sections.

Delete resources scoped to an API proxy revision using the API

Note:You can delete a resource scoped to an API proxy revision if it has not been deployed. After an API proxy revision is deployed, it is immutable.

With hybrid, to delete a resource that is scoped to an API proxy using the API:

  1. Download the API proxy configuration bundle using theGet API proxy revision API with the following options:
    • Set theformat query parameter tobundle
    • Set theAccept header toapplication/zip
  2. Delete the resource file from theAPI proxy configuration bundle.
  3. Upload the API proxy configuration bundle using theUpdate API proxy revision API.

Delete a resource scoped to an environment using the API

Delete a resource scoped to an environment using the API, as described in the following sections.

To delete a resource scoped to an environment using the API, issue aDELETE request to the following resource:https://apigee.googleapis.com/v1/organizations/$ORG/environments/$ENV/resourcefiles/$TYPE/$NAME

The following example deletes thepathSetter.js JavaScript resource file from thetest environment:

curl -X DELETE https://apigee.googleapis.com/v1/organizations/my-organization/environments/test/resourcefiles/jsc/pathSetter.js \  -H "Authorization: Bearer $TOKEN"

Where$TOKEN is set to your OAuth 2.0 access token, as described inObtaining an OAuth 2.0 access token. For information about thecurl options used in this example, seeUsing curl. For a description of environment variables you can use, seeSettingenvironment variables for Apigee API requests.

For more information, seeDelete resource file API.

The following provides an example of the response.

{  "name" : "pathSetter.js",  "type" : "jsc"}

Access the resource

How you access the resource depends on theresource type. For more information, refer to thePolicy reference overview.

The examples in this section demonstrate how to create and manage a JavaScript resource namedpathSetter.js to allow it to be referenced by policies of type JavaScript.

To attach the JavaScript to the Request PostFlow, create a policy calledPathSetterPolicy.xml that references the filepathSetter.js:

<Javascript name='PathSetterPolicy' timeLimit='200'>    <ResourceURL>jsc://pathSetter.js</ResourceURL></Javascript>

Then, reference the policy in the Endpoint configuration:

<PostFlow>  <Request>    <Step><Name>PathSetterPolicy</Name></Step>  </Request><PostFlow>

For more information, seeJavaScript policy.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-15 UTC.