> ## Content Index
> Fetch the complete content index at: https://openlab.app/llms.txt
> Use this file to discover other available public pages before exploring further.

# Create and Edit a Configuration - Programatically
- URL: https://openlab.app/tutorial/create-a-configuration-programatically/
- Published: 2019-05-24T08:50:00.000Z
- Updated: 2020-10-28T12:07:45.000Z
- Description: Learn how to create and edit well configurations programatically with our API
- Author: Andrew Holsæter
- Tags: Python, Configuration, Tutorial, #Import 2026-11-06 18:08

Specific use case:

- Double all the formation strength UCS

Recommended work flow:

- Create a scratch configuration in the [web client](https://live.openlab.app/?ref=openlab.app) to use as a data template to edit.
- Get the configuration data from this scratch configuration via our [API](https://live.openlab.app/swagger/index.html?ref=openlab.app). For this case, we will use python alongside the [openlab module](https://pypi.org/project/openlab/?ref=openlab.app).
- Programmatically edit/make the desired changes to this configuration data.
- Push the edited data to the API

## Walkthrough

*For the final code, jump to the bottom section* 

### Create a scratch configuration

Go to [https://live.openlab.app/](https://live.openlab.app/?ref=openlab.app) and login into your account.

Click the "New configuration" button on the homepage and a dialog box should appear. Choose the template that is most closely related to your configuration and name it. You will delete this configuration later.

Take note of the configuration id.

### Retrieve configuration data

```
import openlab

# Auto-generated credentials from https://live.openlab.app
username="hols@norceresearch.no"
apikey=""
licenseguid=""

session = openlab.http_client()
```

Get the data and print it out to inspect it.

```
# Copy and paste this id from the web client url endpoint
config_id = ""

data = session.configuration_data(config_id)

print(data)
```

*This outputs an* unnavigable *chunk of text, so we inspect the dictionaries keys to give us a clue and help navigate to where UCS might be.*

```
print(data.keys())
```

*output -> \['Rig', 'Fluids', 'GeoThermal', 'Trajectory', 'DrillString', 'GeoPressure', 'Architecture', 'FormationStrength'\]*

Upon further investigation, we see that `FormationStrength` is a list of dictionaries, with each dictionary element consisting of a `UCS` key:value pair. 

Let's print out the last element's `UCS`

```
# Get the last elements UCS
fs_last = data["FormationStrength"][-1]
ucs_last = fs_last["UCS"]

print(ucs_last)
```

### Edit the data

Now that we have found the data we want to make changes to, we can update it. We will assign the original scratch config data a new value (double the original value).

```
# Double each UCS
for fs in data["FormationStrength"]:
    fs["UCS"] *= 2
```

### Push the new configuration data

Finally, we create the new configuration by calling the `create_configuration(name, data)` method, passing in the newly manipulated configuration data.

```
# Create a new configuration with the edited data
name = "Doubled UCS"
session.create_configuration(name, data)
```

Now, we have created a new configuration which has double the UCS as the default template. You can verify this by going to the web client and viewing the new configuration.

## Final Code

```
import openlab

# Initialize an openlab session
session = openlab.http_client()

# Get an existing configuration
config_id = "aee5eb03-f550-4c27-81d9-5673cd9b5876"
data = session.configuration_data(config_id)

# Double each UCS
for fs in data["FormationStrength"]:
    fs["UCS"] *= 2

# Create a new configuraition with the edited data
session.create_configuration("New Configuration", data)
```