# Can leverage the API\_URL constant somehow in the builder context so the form derives the URL instead of hardcoding it

**URL:** <https://forum.builder.io/t/can-leverage-the-api-url-constant-somehow-in-the-builder-context-so-the-form-derives-the-url-instead-of-hardcoding-it/6291>\
**Category:** Technical Questions\
**Tags:** visual-editor\
**Created:** [August 29, 2024, 7:48am UTC](https://forum.builder.io/t/can-leverage-the-api-url-constant-somehow-in-the-builder-context-so-the-form-derives-the-url-instead-of-hardcoding-it/6291 "2024-08-29T07:48:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanket.pokale](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@sanket.pokale](https://forum.builder.io/u/sanket.pokale)\
**Post date:** [August 29, 2024, 7:48am UTC](https://forum.builder.io/t/can-leverage-the-api-url-constant-somehow-in-the-builder-context-so-the-form-derives-the-url-instead-of-hardcoding-it/6291/1 "2024-08-29T07:48:50Z")

</div>

I have created Contact form in content model and form details passing /sending to backend API on submit action in custom code .  
fetch(“[https://abc.dev.azurewebsites.net/v1/forms](https://abc.dev.azurewebsites.net/v1/forms)”, {  
method: “POST”,  
body: formData  
})  
.then(() =\> {  
document.getElementById(‘contactUsForm’).reset();  
state.formSuccess = true  
setTimeout(() =\> {  
state.formSuccess = false  
}, 5000)  
})  
.catch(e =\> {  
state.formError = e.message  
}).finally(() =\> {  
submitButton.disabled = false;  
});

so I don’t wanted to make it hardcode .  
can leverage the API\_URL constant somehow in the builder context so the form derives the URL instead of hardcoding it.

---

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [August 29, 2024, 12:41pm UTC](https://forum.builder.io/t/can-leverage-the-api-url-constant-somehow-in-the-builder-context-so-the-form-derives-the-url-instead-of-hardcoding-it/6291/2 "2024-08-29T12:41:35Z")

</div>

Hello @sanket.pokale,

To configure your contact form’s API URL dynamically within Builder, you can leverage Builder’s custom fields. Here’s how you can do it:

1. **Add a Custom Field to the Model** :

- Go to your [Models](https://builder.io/models).
- Select the model for which you want to add the custom field (e.g., Contact Form).
- Click “Edit Fields”.
- Click “+ New Field”.
- Name the field (e.g., `apiEndpoint`).
- Set the field type to `URL`.
- Save the model.

1. **Use the Custom Field in Your Form Code** : You can fetch the value of the custom field in your form submission code from context object, to know more you can refer to the following forum post [Is it possible to access Page Fields in data bindings? - #4 by nicke920](https://forum.builder.io/t/is-it-possible-to-access-page-fields-in-data-bindings/3393/4)

> **[Custom fields - Builder.io](https://www.builder.io/c/docs/custom-fields)**
>
> Builder is the only Visual Development Platform that offers an AI-powered design-to-code tool, a visual editor, and an enterprise CMS.

Hope this helps!

Thanks,

---

<div class="post-metadata">

**Author:** ![sanket.pokale](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@sanket.pokale](https://forum.builder.io/u/sanket.pokale)\
**Post date:** [August 29, 2024, 12:47pm UTC](https://forum.builder.io/t/can-leverage-the-api-url-constant-somehow-in-the-builder-context-so-the-form-derives-the-url-instead-of-hardcoding-it/6291/3 "2024-08-29T12:47:12Z")

</div>

suppose I wanted to use for another model wanted to make it global as base URL.

---

<div class="post-metadata">

**Author:** ![manish-sharma](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@manish-sharma](https://forum.builder.io/u/manish-sharma)\
**Post date:** [August 29, 2024, 1:02pm UTC](https://forum.builder.io/t/can-leverage-the-api-url-constant-somehow-in-the-builder-context-so-the-form-derives-the-url-instead-of-hardcoding-it/6291/4 "2024-08-29T13:02:31Z")

</div>

Hello @sanket.pokale,

In that case, I would recommend using symbols. Symbols in Builder allow you to create reusable blocks of content that you can include in various parts of your site, and they can contain custom fields that you define, such as a base URL.

> **[Introduction to Symbols - Builder.io](https://www.builder.io/c/docs/symbols-intro)**
>
> Builder is the only Visual Development Platform that offers an AI-powered design-to-code tool, a visual editor, and an enterprise CMS.

> **[Adding Inputs to Symbols - Builder.io](https://www.builder.io/c/docs/adding-inputs-to-symbols)**
>
> Learn how to add editable inputs to Builder.io Symbols, making them customizable for each instance while maintaining centralized control.

---

<div class="post-metadata">

**Author:** ![sanket.pokale](https://avatars.discourse-cdn.com/v4/letter/s/eb8c5e/32.png) [@sanket.pokale](https://forum.builder.io/u/sanket.pokale)\
**Post date:** [August 29, 2024, 1:12pm UTC](https://forum.builder.io/t/can-leverage-the-api-url-constant-somehow-in-the-builder-context-so-the-form-derives-the-url-instead-of-hardcoding-it/6291/5 "2024-08-29T13:12:18Z")

</div>

I Got solution I am taking from context.
