> For the complete documentation index, see [llms.txt](https://prosbcdocs.telcobridges.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://prosbcdocs.telcobridges.com/configuration-details/routing-script-sip-302-handling.md).

# Routing Script - SIP 302 Handling

To enable this, you must use routing scipts. The default behavior of the SBC does not respond to SIP 302 message until you implement below.

First, go to "Routing Script" session in the Web Portal:

<figure><img src="/files/7F9QBOllvcu8uYhLPY0h" alt=""><figcaption></figcaption></figure>

Click on "Create New Script File":

<figure><img src="/files/N6wLwvfTUCr9IKcAEyeS" alt=""><figcaption></figcaption></figure>

Create a new script file with Name “redirect\_routing.rb”. Put the ScriptType as “filter”. Check the checkbox “Load on startup”.

<figure><img src="/files/PUFbhMtyM11NU8FENInO" alt=""><figcaption></figcaption></figure>

Copy and paste below script into the panel. Click "Create".

{% file src="/files/v2mnwTI3EgTF5yHZl1an" %}

It looks like this once created:

<figure><img src="/files/aR2jEqhnmMvqqCc1TGFU" alt=""><figcaption></figcaption></figure>

Go back to the routing script page, look for the "main" script.

<figure><img src="/files/OmMGgE0i7Wuu0pwRET35" alt=""><figcaption></figcaption></figure>

Add below 3 lines into the main script **at the exact place** as below so that redirect\_routing.rb would load correctly.

<figure><img src="/files/50h64T2euGAwAl5kYf4k" alt=""><figcaption></figcaption></figure>

Next, create your NAPs accordingly.

NS: Being the redirect server that will be returing the SIP 302 response.

AS: Being the NAPs where the redirect server will direct the calls to. In this case, there are 2 possible NAPs, OUT\_NAP\_A and OUT\_NAP\_B.

<figure><img src="/files/46rPrtpAHKyhrGLYZnSp" alt=""><figcaption></figcaption></figure>

Next, add a new NAP column, this column will be read by the script to match the SIP URL returned from the redirect server. Enter the value that you expect the redirect server would return. If there is a match, this NAP will be saved and be added to the route list.

<figure><img src="/files/B1Db4OS0phPxG5T0gjQB" alt=""><figcaption></figcaption></figure>

Lastly, add the static routes. Route incoming calls to the redirect server, let it make the decision of where the calls shall go to as specified in the SIP Contact header. Then the SBC will resend the calls according to the list of contacts.

<figure><img src="/files/GjbN9UmxamWTsZZElI5Y" alt=""><figcaption></figcaption></figure>

Now, you are ready to test by sending real incoming calls into the system.

Note: Don't use the "Test Call" feature in the Web Portal for test. You need real incoming calls for the system to correlate the SIP messages properly and responds appropriately to the SIP 302 message.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://prosbcdocs.telcobridges.com/configuration-details/routing-script-sip-302-handling.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
