# SCIM Management Reference

### Create SCIM Connection

Creates a SCIM connection and returns a SCIM API key for your users to provide to their IdP.

#### Arguments
- **customerId** `string` required
  
  The ID of the customer/organization that the SCIM connection is for
- **displayName** `string`
  
  A display name for the SCIM connection
- **scimApiKeyExpiration** `number`
  
  UNIX timestamp when the API key expires (omit for no expiration)
- **customMapping** `ScimUserMappingConfig`
  
  Custom property mapping for this SCIM connection

#### Successful Response
- **connectionId** `string`
  
  The unique identifier for the created SCIM connection
- **scimApiKey** `string`
  
  The API key to provide to the IdP for SCIM provisioning

#### Error Types
- **InvalidFields**
  
  One or more fields have invalid values
- **ScimConnectionForCustomerIdAlreadyExists**
  
  A SCIM connection already exists for this customer ID
- **UnexpectedError**
  
  An unexpected error occurred during the operation

```javascript
const auth = createClient({ url, integrationKey });

const result = await auth.scim.management.createScimConnection({

customerId: "106ce124-1082-4d72-835d-dd1b2172f2fe",

displayName: "Example SCIM Connection",

scimApiKeyExpiration: 1760232804,

customMapping: {

userSchema: [
      {
        outputField: "manager",
        inputPath: "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:manager",
        fallbackInputPaths: [
          "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:managerId"
        ],
        propertyType: {
          dataType: "String"
        },
        displayName: "My Manager",
        description: "Your manager's name",
        warnIfMissing: true,
        defaultValue: "manager@acmeinc.com"
      }
    ]
  }
});

if (result.ok) {
  console.log("SCIM connection created successfully");
  console.log(`Connection ID: ${result.data.connectionId}`);
  console.log(`API Key: ${result.data.scimApiKey}`);
} else {
  console.log(`Error: ${result.error}`);
}
```

### Fetch SCIM Connection

Retrieves SCIM connection details by connection ID or customer ID.

#### Arguments
- **scimConnectionId** `string`
  
  The ID of the SCIM connection
- **customerId** `string`
  
  The customer ID (alternative to scimConnectionId)

#### Successful Response
- **connectionId** `string`
- **customerId** `string`
- **displayName** `string | null`
- **scimApiKeyValidUntil** `number | null`
- **userMapping** `ScimUserMappingConfig`

#### Error Types
- **ScimConnectionNotFound**
  
  The provided SCIM connection ID or customer ID could not be found
- **UnexpectedError**
  
  An unexpected error occurred during the operation

```javascript
const auth = createClient({ url, integrationKey });

const result = await auth.scim.management.fetchScimConnection({
  scimConnectionId: "s8vmjNLuieN1feLOya0mf3"
});

if (result.ok) {
  console.log("SCIM connection fetched successfully");
  console.log(`Connection ID: ${result.data.connectionId}`);
  console.log(`Customer ID: ${result.data.customerId}`);
  console.log(`Display Name: ${result.data.displayName}`);
} else {
  console.log(`Error: ${result.error}`);
}
```

### Patch SCIM Connection

Updates an existing SCIM connection configuration.

#### Arguments
- **scimConnectionId** `string`
- **customerId** `string`
- **displayName** `string`
- **scimApiKeyExpiration** `number`
- **customMapping** `ScimUserMappingConfig`

#### Successful Response
Returns an empty response on success

#### Error Types
- **ScimConnectionNotFound**
- **DisplayNameInvalid**
- **UnexpectedError**

```javascript
const auth = createClient({ url, integrationKey });

const result = await auth.scim.management.patchScimConnection({
  scimConnectionId: "s8vmjNLuieN1feLOya0mf3",
  displayName: "Updated SCIM Connection",
  scimApiKeyExpiration: 1760232804,
  customMapping: {
    userSchema: [
      {
        outputField: "manager",
        inputPath: "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:manager",
        fallbackInputPaths: [
          "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:managerId"
        ],
        propertyType: {
          dataType: "String"
        },
        displayName: "My Manager",
        description: "Your manager's name",
        warnIfMissing: true,
        defaultValue: "manager@acmeinc.com"
      }
    ]
  }
});

if (result.ok) {
  console.log("SCIM connection updated successfully");
} else {
  console.log(`Error: ${result.error}`);
}
```

### Reset SCIM Connection API Key

Invalidates a SCIM connection's API key and generates a new one.

#### Arguments
- **scimConnectionId** `string`
- **customerId** `string`
- **scimApiKeyExpiration** `number`

#### Successful Response
- **connectionId** `string`
- **scimApiKey** `string`

#### Error Types
- **ScimConnectionNotFound**
- **UnexpectedError**

```javascript
const auth = createClient({ url, integrationKey });

const result = await auth.scim.management.resetScimApiKey({
  scimConnectionId: "s8vmjNLuieN1feLOya0mf3",
  scimApiKeyExpiration: 1760232804
});

if (result.ok) {
  console.log("SCIM API key reset successfully");
  console.log(`New API Key: ${result.data.scimApiKey}`);
} else {
  console.log(`Error: ${result.error}`);
}
```

### Get SCIM Connection Users

Fetches user accounts that belong to the provided SCIM connection.

#### Arguments
- **scimConnectionId** `string`
- **customerId** `string`
- **filter** `ScimUsersPageEqualityFilter`
- **pageNumber** `number`
- **pageSize** `number`

#### Successful Response
- **connectionId** `string`
- **users** `array`
- **pageNumber** `number`
- **pageSize** `number`
- **totalResults** `number`

#### Error Types
- **ScimConnectionNotFound**
- **InvalidQueryField**
- **UnexpectedError**

```javascript
const auth = createClient({ url, integrationKey });

const result = await auth.scim.management.getScimUsers({
  scimConnectionId: "s8vmjNLuieN1feLOya0mf3",
  filter: { primaryEmail: "example@propelauth.com" },
  pageNumber: 0,
  pageSize: 100
});

if (result.ok) {
  console.log("SCIM users fetched successfully");
  console.log(`Found ${result.data.totalResults} users`);
  result.data.users.forEach(user => {
    console.log(`User: ${user.primaryEmail}`);
  });
} else {
  console.log(`Error: ${result.error}`);
}
```

### Delete SCIM Connection

Deletes a SCIM connection permanently.

#### Arguments
- **scimConnectionId** `string`
- **customerId** `string`

#### Successful Response
Returns an empty response on success

#### Error Types
- **ScimConnectionNotFound**
- **UnexpectedError**

```javascript
const auth = createClient({ url, integrationKey });

const result = await auth.scim.management.deleteScimConnection({
  scimConnectionId: "s8vmjNLuieN1feLOya0mf3"
});

if (result.ok) {
  console.log("SCIM connection deleted successfully");
} else {
  console.log(`Error: ${result.error}`);
}
```

### SCIM Config

The 'scim_config.jsonc' file allows you to set a default SCIM mapping configuration. This can be used to map properties (name, address, etc.) from your user's SCIM providers to your application.

#### Arguments
- **outputField** `string` required
- **inputPath** `string` required
- **propertyType** `JSON` required
- **fallbackInputPaths** `string[]`
- **displayName** `string`
- **description** `string`
- **warnIfMissing** `boolean`
- **defaultValue** `string`

```json
{
  "userSchema": [
    {
      "outputField": "familyName",
      "inputPath": "name.familyName",
      "fallbackInputPaths": ["lastName", "last_name"],
      "propertyType": {"dataType": "String"},
      "displayName": "Family Name",
      "description": "The user's family name.",
      "warnIfMissing": true,
      "defaultValue": "Unknown"
    },
    {
      "outputField": "givenName",
      "inputPath": "name.givenName",
      "displayName": "Preferred Name",
      "propertyType": {"dataType": "String"}
    },
    {
      "outputField": "phoneNumbers",
      "inputPath": "phoneNumbers[type eq \"work\"].value",
      "displayName": "Work Phone Numbers",
      "propertyType": {"dataType": "List", "itemType": {"dataType": "String"}}
    },
    {
      "outputField": "department",
      "inputPath": "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:department",
      "displayName": "Department",
      "propertyType": {"dataType": "Enum", "options": ["Engineering", "Sales", "Marketing", "Human Resources", "Finance", "Customer Support", "Legal", "Operations"]}
    },
    {
      "outputField": "manager",
      "inputPath": "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:manager",
      "displayName": "My Manager",
      "propertyType": {"dataType": "String"}
    }
  ]
}
```
