> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nixflex.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update phone number credentials

> Update carrier credentials for an imported Nixflex phone number in place. Preserve settings and handle uncertain routing or credential saves safely.

**FIXED · account** A number belongs to an account and agent. On a shared agent always pass that customer’s eligible from\_number.

**NOT OFFERED → do this instead · number** Fixed welcome\_message, language, general timezone and pickup delay belong to the agent. Use Dynamic greeting and the number’s custom\_prompt for its opening. Split agents for different fixed settings.

**YOU CAN CHANGE · number** PATCH fields below. Clearing depends on the field. Null record\_call or require\_booking\_confirmation inherits. Use the number’s voicemail controls. `calcom_timezone_override`, `custom_prompt`, `voice_id`, `sms_reply_enabled`, `sms_prompt`, `web_prompt`, `speaking_rate`, `dtmf_enabled`, `require_booking_confirmation`, `record_call`, `recording_source`, `voicemail_leave_enabled`, `voicemail_message`.

**SCOPE · number** Import an owned carrier number, assign an agent, edit its channels or remove its Nixflex connection.

For a different greeting per business, keep Dynamic greeting on (the default) and put the opening line in that number’s custom\_prompt. For example, “Start every call with: Thank you for calling Oak and Stone”.

[Read the compact AI rules](https://docs.nixflex.com/ai-rules.md#phone-numbers)

Update carrier credentials for an imported Nixflex phone number in place. Preserve settings and handle uncertain routing or credential saves safely.

Method: **POST** · Success: **200** · Scope: **Owning account**

**The important part**

* Use exactly one supported credential pair; do not mix carrier fields.
* This replaces connection credentials. Keep both request and response out of logs.

[Business guide](https://docs.nixflex.com/guides/business/phone-numbers.md) · [Developer guide](https://docs.nixflex.com/guides/developer/phone-numbers.md) · [Glossary](https://docs.nixflex.com/guides/glossary.md)

## Authentication

Use `Authorization: Bearer KEY_ID:KEY_SECRET` for the owning account. An organisation API key has Owner authority. Personal sessions use the role rules documented in [Authentication](https://docs.nixflex.com/api-reference/authentication.md); do not treat a Member session as an API key.

## Request fields

| Field | Type | Required | Default and limits |
| - | - | - | - |
| `phoneNumber` (path) | string | Yes | Owned E.164 number. URL-encode the leading +. |

Choose exactly one carrier pair (option 1).

| Field | Type | Required | Default | Limits and meaning |
| - | - | - | - | - |
| `twilio_sid` | string | Yes | Omitted | |
| `twilio_token` | string | Yes | Omitted | Private submitted credential. Outer whitespace is trimmed; blank values and CR/LF/NUL are refused. At most 4096 characters |

Choose exactly one carrier pair (option 2).

| Field | Type | Required | Default | Limits and meaning |
| - | - | - | - | - |
| `telnyx_api_key` | string | Yes | Omitted | Private submitted credential. Outer whitespace is trimmed; blank values and CR/LF/NUL are refused. At most 4096 characters |
| `telnyx_connection_id` | string | Yes | Omitted | Your existing TeXML app connection ID. At most 200 characters |

Send exactly the credential pair for the number's existing carrier. Twilio uses `twilio_sid` and `twilio_token`; Telnyx uses `telnyx_api_key` and `telnyx_connection_id` for your existing TeXML app. Mixed pairs, extra fields, a provider switch, agent fields and settings fields are refused. Outer whitespace is trimmed; blank values are refused. Telnyx values cannot contain CR, LF or NUL. Secrets are write-only and are never returned.

Verification checks that the new carrier account owns this exact number before changing routing. Twilio voice, SMS and status URLs are repointed to Nixflex and application/trunk overrides are cleared. Telnyx attaches the submitted TeXML app without changing shared app webhooks. The number ID, assigned agent, prompts, switches, pickup delay, integrations and history remain.

A changed Telnyx credential identity clears verification evidence, keeps the public key and needs the existing fresh test-call and approval flow. Identical current credentials retain existing verification when the resource also matches. Do not delete and re-import a number to recover from an uncertain credential update.

## Response fields

`200` returns the following shape.

| Field | Type | Meaning |
| - | - | - |
| `phone_number` | string | Always returned. |
| `provider` | string | Allowed: twilio, telnyx |
| `updated` | boolean | Always returned. |

The response confirms the owned number and carrier. No credential or resource snapshot is returned.

## Example request

Production HTTP examples. Replace the placeholder identifiers with resources owned by the account. Set `NIXFLEX_API_KEY` privately; never print it.

```bash cURL (Bash) theme={"dark"}
curl --request POST \
  --url 'https://api.nixflex.com/v1/phone-numbers/%2B12025550123/credentials' \
  --header "Authorization: Bearer $NIXFLEX_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{"twilio_sid":"AC00000000000000000000000000000000","twilio_token":"REPLACE_PRIVATELY"}'
```

```javascript Node (HTTP) theme={"dark"}
const response = await fetch('https://api.nixflex.com/v1/phone-numbers/%2B12025550123/credentials', {
  method: 'POST',
  headers: { Authorization: `Bearer ${process.env.NIXFLEX_API_KEY}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({"twilio_sid":"AC00000000000000000000000000000000","twilio_token":"REPLACE_PRIVATELY"}),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const result = await response.json();
// Handle the private result without logging it.
```

```python Python (HTTP) theme={"dark"}
import os, json
from urllib.request import Request, urlopen

request = Request('https://api.nixflex.com/v1/phone-numbers/%2B12025550123/credentials', method='POST',
    headers={'Authorization': 'Bearer ' + os.environ['NIXFLEX_API_KEY'], 'Content-Type': 'application/json'},
    data="{\"twilio_sid\":\"AC00000000000000000000000000000000\",\"twilio_token\":\"REPLACE_PRIVATELY\"}".encode("utf-8"))
with urlopen(request, timeout=30) as response:
    result = json.load(response)
# Handle the private result without logging it.
```

```powershell PowerShell (HTTP) theme={"dark"}
$headers = @{ Authorization = "Bearer $env:NIXFLEX_API_KEY" }
$body = '{"twilio_sid":"AC00000000000000000000000000000000","twilio_token":"REPLACE_PRIVATELY"}'
$result = Invoke-RestMethod -Method POST -Uri 'https://api.nixflex.com/v1/phone-numbers/%2B12025550123/credentials' -Headers $headers -DisableKeepAlive -ContentType "application/json" -Body ([Text.Encoding]::UTF8.GetBytes($body))
# Handle $result privately.
```

## Example response

Illustrative response with placeholder identifiers.

```json Response theme={"dark"}
{
  "phone_number": "+12025550123",
  "provider": "twilio",
  "updated": true
}
```

## Errors

Branch on `error.code`, not the wording of `error.message`. The envelope includes `type`, `code`, `message`, `doc_url` and `details`.

| Status / code | What it means | What to do |
| - | - | - |
| 400 · `invalid_request` | invalid\_request, invalid\_credentials | Correct the named field or query using the request table before trying again. |
| 400 · `invalid_credentials` | The supplied credential pair is invalid. | Supply exactly one complete supported credential pair through private secret handling. |
| 401 · `unauthorized` | The credential is missing or invalid. | Check the full account credential and API host privately; stop the retry loop. |
| 403 · `permission_denied` | This actor cannot perform the operation. | Resolve the account or role restriction through an authorised person. |
| 403 · `account_unavailable` | The account is unavailable for this operation. | Resolve the account or role restriction through an authorised person. |
| 404 · `number_not_found` | The number is absent or inaccessible to this account. | Check the exact owned identifier and current resource state; do not probe another account. |
| 404 · `number_not_in_account` | The number does not belong to this account. | Check the exact owned identifier and current resource state; do not probe another account. |
| 409 · `carrier_mismatch` | The credentials do not match the existing number carrier. | Use credentials for this number’s existing carrier; this endpoint does not migrate it. |
| 409 · `number_operation_pending` | Another number operation is unfinished. | Wait for the existing number operation to settle and read the number again. |
| 409 · `number_release_pending` | Number removal or release is unfinished. | Wait for removal/release work to settle; do not overwrite credentials during it. |
| 429 · `rate_limit_exceeded` | The request limit was reached. | Stop automatic retries; wait for the limit and reconcile state before a deliberate action. |
| 503 · `carrier_unavailable` | The carrier could not complete the request. | Treat the outcome as uncertain and read the affected resource before another deliberate change. |
| 503 · `credential_update_unavailable` | The credential change could not be confirmed. | Treat the outcome as uncertain and read the affected resource before another deliberate change. |
| 503 · `carrier_outcome_unknown` | The carrier change outcome cannot be confirmed. | Reconcile the existing carrier change; do not submit different credentials or assume no change occurred. |
| 503 · `credential_save_pending` | The carrier change succeeded; its local save is unfinished. | The carrier change is confirmed. Deliberately retry identical details only to finish the local save. |

`invalid_credentials` is HTTP 400, not an API-authentication 401. `carrier_outcome_unknown`: stop automatic retries and contact support with `details.operation_id` if present. `credential_save_pending`: the carrier change is confirmed; deliberately resubmit identical details to finish the local save without a second carrier change. A pending number/release operation must be resolved first. Never use delete/re-import as recovery.

## Retry and idempotency

Disable automatic write retries. A lost response leaves the result uncertain; read the affected resource before another deliberate action. No general Idempotency-Key replay guarantee applies. See [retry rules](https://docs.nixflex.com/api-reference/retries.md).

## Related endpoints

* [List phone numbers](https://docs.nixflex.com/api-reference/phone-numbers/list.md)
* [Get a phone number](https://docs.nixflex.com/api-reference/phone-numbers/get.md)
* [Errors and recovery](https://docs.nixflex.com/api-reference/errors.md#error-envelope)


## OpenAPI

````yaml api-reference/public.openapi.json POST /phone-numbers/{phoneNumber}/credentials
openapi: 3.1.0
info:
  title: Nixflex public API
  version: 1.0.0
  description: >-
    Nixflex API reference for agents, calls, messaging, knowledge, organisations
    and integrations. Authenticate with the owning account and follow each
    operation’s permissions, response and retry contract.
servers:
  - url: https://api.nixflex.com/v1
security:
  - bearerAuth: []
paths:
  /phone-numbers/{phoneNumber}/credentials:
    post:
      tags:
        - Phone numbers
      summary: Update phone number credentials
      description: >-
        Organisation API key or verified dashboard session. Owner/Admin can
        write; Member can read. Other organisations cannot access this number.
      operationId: updatePhoneNumberCredentials
      parameters:
        - name: phoneNumber
          in: path
          required: true
          description: Owned E.164 number. URL-encode the leading +.
          schema:
            type: string
            pattern: ^\+[1-9][0-9]{1,14}$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - type: object
                  properties:
                    twilio_sid:
                      type: string
                      pattern: ^AC[a-fA-F0-9]{32}$
                      writeOnly: true
                    twilio_token:
                      type: string
                      minLength: 1
                      maxLength: 4096
                      pattern: ^(?=[^\r\n\u0000]*\S)[^\r\n\u0000]+$
                      writeOnly: true
                      description: >-
                        Private submitted credential. Outer whitespace is
                        trimmed; blank values and CR/LF/NUL are refused.
                  required:
                    - twilio_sid
                    - twilio_token
                  additionalProperties: false
                - type: object
                  properties:
                    telnyx_api_key:
                      type: string
                      minLength: 1
                      maxLength: 4096
                      pattern: ^(?=[^\r\n\u0000]*\S)[^\r\n\u0000]+$
                      writeOnly: true
                      description: >-
                        Private submitted credential. Outer whitespace is
                        trimmed; blank values and CR/LF/NUL are refused.
                    telnyx_connection_id:
                      type: string
                      minLength: 1
                      maxLength: 200
                      pattern: ^(?=[^\r\n\u0000]*\S)[^\r\n\u0000]+$
                      writeOnly: true
                      description: Your existing TeXML app connection ID.
                  required:
                    - telnyx_api_key
                    - telnyx_connection_id
                  additionalProperties: false
      responses:
        '200':
          description: 'Success. Cache-Control: no-store.'
          content:
            application/json:
              schema:
                type: object
                properties:
                  phone_number:
                    type: string
                    pattern: ^\+[1-9][0-9]{1,14}$
                  provider:
                    type: string
                    enum:
                      - twilio
                      - telnyx
                  updated:
                    type: boolean
                    const: true
                required:
                  - phone_number
                  - provider
                  - updated
                additionalProperties: false
              example:
                phone_number: '+12025550123'
                provider: twilio
                updated: true
        '400':
          description: >-
            invalid_request, invalid_credentials. Standard error envelope;
            branch on error.code.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      doc_url:
                        type: string
                      details:
                        type: object
                        additionalProperties: true
                    required:
                      - type
                      - code
                      - message
                      - doc_url
                required:
                  - error
        '401':
          description: unauthorized. Standard error envelope; branch on error.code.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      doc_url:
                        type: string
                      details:
                        type: object
                        additionalProperties: true
                    required:
                      - type
                      - code
                      - message
                      - doc_url
                required:
                  - error
        '403':
          description: >-
            permission_denied, account_unavailable. Standard error envelope;
            branch on error.code.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      doc_url:
                        type: string
                      details:
                        type: object
                        additionalProperties: true
                    required:
                      - type
                      - code
                      - message
                      - doc_url
                required:
                  - error
        '404':
          description: >-
            number_not_found, number_not_in_account. Standard error envelope;
            branch on error.code.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      doc_url:
                        type: string
                      details:
                        type: object
                        additionalProperties: true
                    required:
                      - type
                      - code
                      - message
                      - doc_url
                required:
                  - error
        '409':
          description: >-
            carrier_mismatch, number_operation_pending, number_release_pending.
            Standard error envelope; branch on error.code.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      doc_url:
                        type: string
                      details:
                        type: object
                        additionalProperties: true
                    required:
                      - type
                      - code
                      - message
                      - doc_url
                required:
                  - error
        '429':
          description: rate_limit_exceeded. Standard error envelope; branch on error.code.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      doc_url:
                        type: string
                      details:
                        type: object
                        additionalProperties: true
                    required:
                      - type
                      - code
                      - message
                      - doc_url
                required:
                  - error
        '503':
          description: >-
            carrier_unavailable, credential_update_unavailable,
            carrier_outcome_unknown, credential_save_pending. Standard error
            envelope; branch on error.code.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      doc_url:
                        type: string
                      details:
                        type: object
                        additionalProperties: true
                    required:
                      - type
                      - code
                      - message
                      - doc_url
                required:
                  - error
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        KEY_ID:KEY_SECRET from the owning account. Keep it server-side. A
        verified personal dashboard Bearer session may be used where the
        operation documents role-based access.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.