# post\_\_settings\_organization

`POST /settings/organization`

*Update Organization Settings (Full Replacement)*

Update the organization settings with a complete replacement. This endpoint replaces all existing organization settings with the provided settings object. The user must be authenticated and associated with an organization.

#### Request Body Schema <a href="#post__settings_organization-requestbodyschema" id="post__settings_organization-requestbodyschema"></a>

| Name       | Type   | Required | Restrictions | Description                                           |
| ---------- | ------ | -------- | ------------ | ----------------------------------------------------- |
| » settings | object | true     | none         | Complete settings object to replace existing settings |

#### TypeScript Client Library

```typescript
// Using the Flashback TypeScript client
import { FlashbackClient } from '@flashback/client';

const client = new FlashbackClient({ accessToken: 'your-access-token' });

// Update organization settings with full replacement
try {
  const result = await client.settings.organization.update({
    settings: {
      defaultStorageType: 'S3',
      maxFileSize: '10GB',
      retentionPolicy: { enabled: true, days: 365 },
      security: { requireMFA: true, sessionTimeout: 3600 }
    }
  });
  console.log('Organization settings updated:', result);
} catch (error) {
  console.error('Failed to update organization settings:', error);
}
```

#### Code Samples

{% tabs %}
{% tab title="Shell" %}

```shell
# You can also use wget
curl -X POST https://backend.flashback.tech/settings/organization \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer {access-token}' \
  -H 'Content-Type: application/json' \
  -d '{
    "settings": {
      "defaultStorageType": "S3",
      "maxFileSize": "10GB",
      "retentionPolicy": {
        "enabled": true,
        "days": 365
      },
      "security": {
        "requireMFA": true,
        "sessionTimeout": 3600
      }
    }
  }'
```

{% endtab %}

{% tab title="HTTP" %}

```http
POST https://backend.flashback.tech/settings/organization HTTP/1.1
Host: localhost:3000
Accept: application/json
Authorization: Bearer {access-token}
Content-Type: application/json

{
  "settings": {
    "defaultStorageType": "S3",
    "maxFileSize": "10GB",
    "retentionPolicy": {
      "enabled": true,
      "days": 365
    },
    "security": {
      "requireMFA": true,
      "sessionTimeout": 3600
    }
  }
}
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const headers = {
  'Accept':'application/json',
  'Authorization':'Bearer {access-token}',
  'Content-Type':'application/json'
};

const body = {
  "settings": {
    "defaultStorageType": "S3",
    "maxFileSize": "10GB",
    "retentionPolicy": {
      "enabled": true,
      "days": 365
    },
    "security": {
      "requireMFA": true,
      "sessionTimeout": 3600
    }
  }
};

fetch('https://backend.flashback.tech/settings/organization',
{
  method: 'POST',
  headers: headers,
  body: JSON.stringify(body)
})
.then(function(res) {
    return res.json();
}).then(function(body) {
    console.log(body);
});
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'rest-client'
require 'json'

headers = {
  'Accept' => 'application/json',
  'Authorization' => 'Bearer {access-token}',
  'Content-Type' => 'application/json'
}

body = {
  "settings" => {
    "defaultStorageType" => "S3",
    "maxFileSize" => "10GB",
    "retentionPolicy" => {
      "enabled" => true,
      "days" => 365
    },
    "security" => {
      "requireMFA" => true,
      "sessionTimeout" => 3600
    }
  }
}

result = RestClient.post 'https://backend.flashback.tech/settings/organization',
  body.to_json, headers: headers

p JSON.parse(result)
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

headers = {
  'Accept': 'application/json',
  'Authorization': 'Bearer {access-token}',
  'Content-Type': 'application/json'
}

body = {
  "settings": {
    "defaultStorageType": "S3",
    "maxFileSize": "10GB",
    "retentionPolicy": {
      "enabled": True,
      "days": 365
    },
    "security": {
      "requireMFA": True,
      "sessionTimeout": 3600
    }
  }
}

r = requests.post('https://backend.flashback.tech/settings/organization', 
                 headers=headers, 
                 data=json.dumps(body))

print(r.json())
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

require 'vendor/autoload.php';

$headers = array(
    'Accept' => 'application/json',
    'Authorization' => 'Bearer {access-token}',
    'Content-Type' => 'application/json',
);

$client = new \GuzzleHttp\Client();

// Define array of request body.
$request_body = array(
    'settings' => array(
        'defaultStorageType' => 'S3',
        'maxFileSize' => '10GB',
        'retentionPolicy' => array(
            'enabled' => true,
            'days' => 365
        ),
        'security' => array(
            'requireMFA' => true,
            'sessionTimeout' => 3600
        )
    )
);

try {
    $response = $client->request('POST','https://backend.flashback.tech/settings/organization', array(
        'headers' => $headers,
        'json' => $request_body,
       )
    );
    print_r($response->getBody()->getContents());
 }
 catch (\GuzzleHttp\Exception\BadResponseException $e) {
    // handle exception or api errors.
    print_r($e->getMessage());
 }
```

{% endtab %}

{% tab title="Java" %}

```java
URL obj = new URL("https://backend.flashback.tech/settings/organization");
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Accept", "application/json");
con.setRequestProperty("Authorization", "Bearer {access-token}");
con.setRequestProperty("Content-Type", "application/json");

String jsonInputString = "{\"settings\":{\"defaultStorageType\":\"S3\",\"maxFileSize\":\"10GB\",\"retentionPolicy\":{\"enabled\":true,\"days\":365},\"security\":{\"requireMFA\":true,\"sessionTimeout\":3600}}}";

con.setDoOutput(true);
try(OutputStream os = con.getOutputStream()) {
    byte[] input = jsonInputString.getBytes("utf-8");
    os.write(input, 0, input.length);           
}

int responseCode = con.getResponseCode();
BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
    response.append(inputLine);
}
in.close();
System.out.println(response.toString());
```

{% endtab %}

{% tab title="Go" %}

```go
package main

import (
       "bytes"
       "encoding/json"
       "net/http"
)

func main() {

    headers := map[string][]string{
        "Accept": []string{"application/json"},
        "Authorization": []string{"Bearer {access-token}"},
        "Content-Type": []string{"application/json"},
    }

    body := map[string]interface{}{
        "settings": map[string]interface{}{
            "defaultStorageType": "S3",
            "maxFileSize":       "10GB",
            "retentionPolicy": map[string]interface{}{
                "enabled": true,
                "days":    365,
            },
            "security": map[string]interface{}{
                "requireMFA":    true,
                "sessionTimeout": 3600,
            },
        },
    }

    jsonData, _ := json.Marshal(body)
    data := bytes.NewBuffer(jsonData)
    req, err := http.NewRequest("POST", "https://backend.flashback.tech/settings/organization", data)
    req.Header = headers

    client := &http.Client{}
    resp, err := client.Do(req)
    // ...
}
```

{% endtab %}
{% endtabs %}

> Example responses

> 200 Response

```json
{
  "success": true,
  "message": "Organization settings updated successfully"
}
```

> 400 Response

```json
{
  "success": false,
  "message": "Failed to update organization settings"
}
```

> 404 Response

```json
{
  "success": false,
  "message": "User not associated with any organization"
}
```

> 500 Response

```json
{
  "success": false,
  "message": "Internal server error",
  "error": "Database connection failed"
}
```

#### Responses <a href="#post__settings_organization-responses" id="post__settings_organization-responses"></a>

| Status | Meaning                                                                    | Description                                | Schema |
| ------ | -------------------------------------------------------------------------- | ------------------------------------------ | ------ |
| 200    | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1)                    | Organization settings updated successfully | Inline |
| 400    | [Bad Request](https://tools.ietf.org/html/rfc7231#section-6.5.1)           | Failed to update organization settings     | Inline |
| 404    | [Not Found](https://tools.ietf.org/html/rfc7231#section-6.5.4)             | User not associated with organization      | Inline |
| 500    | [Internal Server Error](https://tools.ietf.org/html/rfc7231#section-6.6.1) | Internal server error                      | Inline |

#### Response Schema <a href="#post__settings_organization-responseschema" id="post__settings_organization-responseschema"></a>

Status Code **200**

| Name      | Type    | Required | Restrictions | Description                              |
| --------- | ------- | -------- | ------------ | ---------------------------------------- |
| » success | boolean | true     | none         | Indicates if the request was successful  |
| » message | string  | true     | none         | Success message describing the operation |

Status Code **400**

| Name      | Type    | Required | Restrictions | Description                        |
| --------- | ------- | -------- | ------------ | ---------------------------------- |
| » success | boolean | true     | none         | Always false for error responses   |
| » message | string  | true     | none         | Error message describing the issue |

Status Code **404**

| Name      | Type    | Required | Restrictions | Description                        |
| --------- | ------- | -------- | ------------ | ---------------------------------- |
| » success | boolean | true     | none         | Always false for error responses   |
| » message | string  | true     | none         | Error message describing the issue |

Status Code **500**

| Name      | Type    | Required | Restrictions | Description                           |
| --------- | ------- | -------- | ------------ | ------------------------------------- |
| » success | boolean | true     | none         | Always false for error responses      |
| » message | string  | true     | none         | Error message describing the issue    |
| » error   | string  | false    | none         | Additional error details if available |

#### DTOs

**UpdateSettingsRequest**

```typescript
export interface UpdateSettingsRequest {
  // Using Record<string, any> for maximum flexibility - settings can contain any JSON-serializable data
  settings: Record<string, any>;
}
```

**SettingsErrorResponse**

```typescript
export interface SettingsErrorResponse {
  success: false;
  message: string;
  error?: string;
}
```
