You're viewing **Apigee Edge** documentation.  
[Go to the
**Apigee X** documentation](http://cloud.google.com/apigee/docs/api-platform/develop/incorporating-procedural-code-api-proxy). info

You can add code in procedural languages such as JavaScript, Java, and Python, then call out
to that code from other parts of an API proxy. Support for procedural code is designed to make it
easier for you to implement complex handling of flow variables, faults, and request and response
bodies.

With procedural code, you can:

- Create or manipulate complex body values, such as request and response values.
- Rewrite URLs, such as to mask a target endpoint URL.
- Add other logic not available with included policies.

## How it works

You use a policy specific to the language in order to make calls from a proxy flow to your
included code. For each of the supported languages, Apigee Edge includes a separate policy:
[JavaScript policy](https://docs.apigee.com/api-platform/reference/policies/javascript-policy.md.txt), [Java Callout policy](https://docs.apigee.com/api-platform/reference/policies/java-callout-policy.md.txt), and [Python Script policy](https://docs.apigee.com/api-platform/reference/policies/python-script-policy.md.txt).

The following describes, at a high level, one way this works. Be sure to see the policy
references for more details.

1. In a separate file, write the code you're going to use.
2. In your code, put the result of the code's processing into an Apigee Edge flow variable. You'll retrieve the variable value elsewhere in your API proxy. For more about flow
   variables, see [Managing
   proxy state with flow variables](https://docs.apigee.com/api-platform/fundamentals/introduction-flow-variables).

3. Add your file (or JAR) as a resource file to your API proxy. For more about resource files, see [Resource files](https://docs.apigee.com/api-platform/develop/resource-files.md.txt).

4. Add the policy corresponding to the language you're using. Configure the policy to make a call to your code from the desired place in your API
   proxy's flow.

5. Use a policy to retrieve the code's value from the flow variable.

## Limitations

The Apigee Edge security model does not permit system calls such as network I/O, filesystem
read/writes, current user info, process list, and CPU/memory utilization. Although some such
calls may be functional, they are unsupported and liable to be actively disabled at any time. For
forward compatibility, you should avoid making such calls in your code.

Other limitations may exist for each supported language, as described in the language's
corresponding policy reference.

## Supported languages

### JavaScript

Support for JavaScript includes a full object model for handling variables and values specific
to an API proxy. For more, see [JavaScript object model](https://docs.apigee.com/api-platform/reference/javascript-object-model.md.txt).

For policy reference information and examples, see [JavaScript policy](https://docs.apigee.com/api-platform/reference/policies/javascript-policy.md.txt) and [Programming API
proxies with JavaScript](https://docs.apigee.com/api-platform/samples/cookbook/programming-api-proxies-javascript). For sample code, search [Samples
list](https://docs.apigee.com/api-platform/samples/samples-reference) for those with JavaScript included.

### Java

Use the [Java Callout
policy](https://docs.apigee.com/api-platform/reference/policies/java-callout-policy) to make calls to Java code from your proxy's flow. The policy reference topic includes
examples.

You might also be interested in the following topics:

- [How to create a Java
  callout](https://docs.apigee.com/api-platform/samples/cookbook/how-create-java-callout)
- [How to handle
  Java Callout errors](https://docs.apigee.com/api-platform/samples/cookbook/how-handle-java-callout-errors)
- [How to use
  properties in a Java callout](https://docs.apigee.com/api-platform/samples/cookbook/how-use-properties-java-callout)

For sample code, search [Samples
list](https://docs.apigee.com/api-platform/samples/samples-reference) for those with Java included.

### Python

Use the [Python Script
policy](https://docs.apigee.com/api-platform/reference/policies/python-script-policy) to call out to Python code.

For sample code, search [Samples
list](https://docs.apigee.com/api-platform/samples/samples-reference) for those with Python included.