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

# Import Identity Sources

> Import Identity Sources for a specific Identity Template in the indicated Environment. This API call is designed to support CREATE and UPDATE operations for Identity Sources. <br> <br>
<h2>Notice</h2>Accessing the API call is through a dedicated domain/URL, according to your PlainID Tenant Location<li><b>United States (US)</b> - `https://api.us1.plainid.io`</li><li><b>Canada (CA)</b> - `https://api.ca1.plainid.io`</li><li><b>Europe (EU)</b> - `https://api.eu1.plainid.io`</li> <br> <h2>Using HTML Encoded Special Characters</h2> <p>Use HTML encoded patterns when working with values that contain special characters like spaces, dashes, etc. Refer to this <a href="https://www.w3schools.com/tags/ref_urlencode.ASP" target="_blank">HTML URL Encoding Reference</a> for a full list.</p> <br>

<h2>Important note about headers</h2> <p>Refer to the headers below to modify your cURL sample. Check if the following headers are in the sample, if not, ensure you add it to your API tool. </p> <h3>Headers</h3> *Required <table><thead> <tr> <th>Header</th> <th>Value</th> <th>cURL Line</th> </tr></thead> <tbody> <tr> <td>Accept</td> <td>`application/json`</td> <td> `-H "Accept:application/json"`</td> </tr> <tr> <td>Content-Type</td> <td>`application/json`</td> <td> `-H "Content-Type:application/json"`</td> </tr> </tbody> </table> <br> <h3>cURL Sample Guidelines</h3> <p>In order for the relevant parameters to appear in the cURL sample, you can input the values in the interactive API console on the right in the Try It or Code Sample tabs. You can then copy the cURL sample from the Code Sample tab in the correct format.</p>

## OpenAPI

````json PUT /api/1.0/identity-templates/{envId}/{identityTemplateId}/identity-sources
{
  "openapi": "3.0.3",
  "info": {
    "title": "Management APIs",
    "version": "1.0.0",
    "contact": {
      "name": "PlainID",
      "url": "https://plainid.com",
      "email": "contact@plainid.com"
    },
    "license": {
      "name": "Commercial",
      "url": "https://plainid.com/license"
    },
    "termsOfService": "https://www.plainid.com/terms/",
    "description": "<h3>The PlainID Authorization Platform provides Management capabilities through the APIs below.</h3><h4> To access the Management APIs, make sure to enter your dedicated domain according to your PlainID Tenant Location:<table><thead><tr><th>Region</th><th>Base URL</th></tr></thead><tbody><tr><td>United States (US)</td><td>https://api.us1.plainid.io</td></tr><tr><td>Canada (CA)</td><td>https://api.ca1.plainid.io</td></tr><tr><td>Europe (EU)</td><td>https://api.eu1.plainid.io</td></tr><tr><td>Local PAA</td><td>https://api.plainid.local</td></tr></tbody></table>"
  },
  "servers": [
    {
      "description": "United States",
      "url": "https://api.us1.plainid.io"
    },
    {
      "description": "Europe",
      "url": "https://api.eu1.plainid.io"
    },
    {
      "description": "Canada",
      "url": "https://api.ca1.plainid.io"
    },
    {
      "description": "Local PAA",
      "url": "https://api.plainid.local"
    }
  ],
  "paths": {
    "/api/1.0/identity-templates/{envId}/{identityTemplateId}/identity-sources": {
      "put": {
        "summary": "Import Identity Sources",
        "operationId": "importIdentitySources",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "description": "Import Identity Sources for a specific Identity Template in the indicated Environment. This API call is designed to support CREATE and UPDATE operations for Identity Sources. <br> <br>\n<h2>Notice</h2>Accessing the API call is through a dedicated domain/URL, according to your PlainID Tenant Location<li><b>United States (US)</b> - `https://api.us1.plainid.io`</li><li><b>Canada (CA)</b> - `https://api.ca1.plainid.io`</li><li><b>Europe (EU)</b> - `https://api.eu1.plainid.io`</li> <br> <h2>Using HTML Encoded Special Characters</h2> <p>Use HTML encoded patterns when working with values that contain special characters like spaces, dashes, etc. Refer to this <a href=\"https://www.w3schools.com/tags/ref_urlencode.ASP\" target=\"_blank\">HTML URL Encoding Reference</a> for a full list.</p> <br>\n\n<h2>Important note about headers</h2> <p>Refer to the headers below to modify your cURL sample. Check if the following headers are in the sample, if not, ensure you add it to your API tool. </p> <h3>Headers</h3> *Required <table><thead> <tr> <th>Header</th> <th>Value</th> <th>cURL Line</th> </tr></thead> <tbody> <tr> <td>Accept</td> <td>`application/json`</td> <td> `-H \"Accept:application/json\"`</td> </tr> <tr> <td>Content-Type</td> <td>`application/json`</td> <td> `-H \"Content-Type:application/json\"`</td> </tr> </tbody> </table> <br> <h3>cURL Sample Guidelines</h3> <p>In order for the relevant parameters to appear in the cURL sample, you can input the values in the interactive API console on the right in the Try It or Code Sample tabs. You can then copy the cURL sample from the Code Sample tab in the correct format.</p>",
        "tags": [
          "Identity Sources"
        ],
        "parameters": [
          {
            "name": "envId",
            "in": "path",
            "required": "true",
            "schema": {
              "type": "string",
              "format": "uuid"
            },
            "description": "The Environment ID can be found under the Details Tab in the Environment Settings."
          },
          {
            "name": "identityTemplateId",
            "in": "path",
            "required": "true",
            "schema": {
              "type": "string"
            },
            "description": "The Identity Template ID. This can be found in the Details tab in the Identity Workspace Settings."
          }
        ],
        "requestBody": {
          "description": "Identity Sources to import.",
          "required": "true",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImportIdentitySourcesRequest"
              },
              "examples": {
                "example": {
                  "value": {
                    "sources": [
                      {
                        "sourceId": "REQUEST_INPUT",
                        "displayName": "PDP Request",
                        "description": null,
                        "sourceType": "REQUEST_INPUT",
                        "sourceMetaData": {
                          "logoUrl": null
                        }
                      },
                      {
                        "sourceId": "REQUEST_MAPPERS",
                        "displayName": "Request Mappers",
                        "description": null,
                        "sourceType": "REQUEST_MAPPERS",
                        "sourceMetaData": {
                          "logoUrl": null
                        }
                      },
                      {
                        "sourceId": "ds_users",
                        "displayName": "users1",
                        "description": null,
                        "sourceType": "EXTERNAL_INPUT",
                        "sourceMetaData": {
                          "logoUrl": null,
                          "paaGroupId": "TestPAA",
                          "viewName": "v_users"
                        }
                      },
                      {
                        "sourceId": "CALCULATED",
                        "displayName": "Calculated Functions",
                        "description": null,
                        "sourceType": "CALCULATED",
                        "sourceMetaData": {
                          "logoUrl": null
                        }
                      },
                      {
                        "sourceId": "s122432",
                        "displayName": "Table 1",
                        "description": null,
                        "sourceType": "EXTERNAL_OUTPUT",
                        "sourceMetaData": {
                          "logoUrl": null,
                          "fqp": "adminDB_public_TABLE1"
                        }
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Successful operation",
            "headers": {
              "x-request-id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                },
                "description": "The ID of the request"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IdentitySourcesResponse"
                },
                "examples": {
                  "example": {
                    "value": {
                      "data": {
                        "sources": [
                          {
                            "sourceId": "REQUEST_INPUT",
                            "displayName": "PDP Request",
                            "description": null,
                            "sourceType": "REQUEST_INPUT",
                            "sourceMetaData": {
                              "logoUrl": null
                            }
                          },
                          {
                            "sourceId": "REQUEST_MAPPERS",
                            "displayName": "Request Mappers",
                            "description": null,
                            "sourceType": "REQUEST_MAPPERS",
                            "sourceMetaData": {
                              "logoUrl": null
                            }
                          },
                          {
                            "sourceId": "ds_users",
                            "displayName": "users1",
                            "description": null,
                            "sourceType": "EXTERNAL_INPUT",
                            "sourceMetaData": {
                              "logoUrl": null,
                              "paaGroupId": "TestPAA",
                              "viewName": "v_users"
                            }
                          },
                          {
                            "sourceId": "CALCULATED",
                            "displayName": "Calculated Functions",
                            "description": null,
                            "sourceType": "CALCULATED",
                            "sourceMetaData": {
                              "logoUrl": null
                            }
                          },
                          {
                            "sourceId": "s122432",
                            "displayName": "Table 1",
                            "description": null,
                            "sourceType": "EXTERNAL_OUTPUT",
                            "sourceMetaData": {
                              "logoUrl": null,
                              "fqp": "adminDB_public_TABLE1"
                            }
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation Error",
            "headers": {
              "x-request-id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                },
                "description": "The ID of the request"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "unimportableSourceTypeError": {
                    "$ref": "#/components/examples/UnimportableSourceTypeError"
                  },
                  "singletonIdentitySourceTypeError": {
                    "$ref": "#/components/examples/SingletonIdentitySourceTypeError"
                  },
                  "uneditableSourceFieldError": {
                    "$ref": "#/components/examples/UneditableSourceFieldError"
                  },
                  "invalidSourceTypeValidationMessage": {
                    "$ref": "#/components/examples/InvalidSourceTypeValidationMessage"
                  },
                  "identitySourceIDAlreadyExistsError": {
                    "$ref": "#/components/examples/IdentitySourceIDAlreadyExistsError"
                  },
                  "identitySourceDisplayNameAlreadyExistsError": {
                    "$ref": "#/components/examples/IdentitySourceDisplayNameAlreadyExistsError"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "headers": {
              "x-request-id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                },
                "description": "The ID of the request"
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "headers": {
              "x-request-id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                },
                "description": "The ID of the request"
              }
            }
          },
          "404": {
            "description": "Object not found",
            "headers": {
              "x-request-id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                },
                "description": "The ID of the request"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "examples": {
                  "environmentNotFoundError": {
                    "$ref": "#/components/examples/EnvironmentNotFoundError"
                  },
                  "identityTemplateNotFoundError": {
                    "$ref": "#/components/examples/identityTemplateNotFound"
                  },
                  "paaGroupNotFoundError": {
                    "$ref": "#/components/examples/PAAGroupNotFoundError"
                  }
                }
              }
            }
          },
          "422": {
            "description": "Payload Validation Error",
            "headers": {
              "x-request-id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                },
                "description": "The ID of the request"
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "headers": {
              "x-request-id": {
                "schema": {
                  "type": "string",
                  "format": "uuid"
                },
                "description": "The ID of the request"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ImportIdentitySourcesRequest": {
        "type": "object",
        "description": "Request payload for importing Identity Sources",
        "required": [
          "sources"
        ],
        "properties": {
          "sources": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/IdentitySource"
            },
            "description": "List of Identity Sources to import"
          }
        }
      },
      "IdentitySourcesResponse": {
        "type": "object",
        "description": "Response payload for Identity Sources operations",
        "required": [
          "templateId",
          "sources"
        ],
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "sources": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/IdentitySource"
                },
                "description": "List of Identity Sources"
              }
            }
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "details": {
            "type": "string"
          }
        }
      },
      "IdentitySource": {
        "type": "object",
        "description": "Identity Source",
        "required": [
          "sourceId",
          "displayName",
          "sourceType"
        ],
        "properties": {
          "sourceId": {
            "type": "string",
            "minLength": "1",
            "maxLength": "128",
            "description": "The unique identifier for the Identity Source"
          },
          "displayName": {
            "type": "string",
            "minLength": "1",
            "maxLength": "100",
            "description": "Display name for the source"
          },
          "description": {
            "type": "string",
            "maxLength": "200",
            "description": "Description of Source"
          },
          "sourceType": {
            "type": "string",
            "enum": [
              "REQUEST_INPUT",
              "REQUEST_MAPPERS",
              "EXTERNAL_INPUT",
              "CALCULATED",
              "EXTERNAL_OUTPUT",
              "INTERNAL_INPUT"
            ],
            "description": "Type of source"
          },
          "sourceMetaData": {
            "type": "object",
            "description": "Additional metadata for the Identity Source",
            "properties": {
              "logoUrl": {
                "type": "string",
                "format": "uri",
                "description": "Source Logo URL"
              },
              "paaGroupId": {
                "type": "string",
                "description": "PAAGroup ID associated with the environment or tenant. PAA Groups at the Tenant level have a suffix of _GLOBAL. (for EXTERNAL_INPUT sources)",
                "maxLength": "128"
              },
              "viewName": {
                "type": "string",
                "description": "View associated with the source (for EXTERNAL_INPUT sources)"
              },
              "fqp": {
                "type": "string",
                "description": "FQP - Full Qualified Path (e.g. DB.schema.Table) (for EXTERNAL_OUTPUT sources)"
              }
            }
          }
        }
      }
    },
    "examples": {
      "UnimportableSourceTypeError": {
        "value": {
          "errors": [
            {
              "code": "EMIS-001",
              "id": "EQ7CMX",
              "status": "400",
              "name": "UnimportableSourceTypeError",
              "message": "Cannot import or modify source of unimportable type: [REQUEST_INPUT]"
            }
          ]
        }
      },
      "SingletonIdentitySourceTypeError": {
        "value": {
          "errors": [
            {
              "code": "EMIS-002",
              "id": "EQ7CMX",
              "status": "400",
              "name": "SingletonIdentitySourceTypeError",
              "message": "Only one Identity Source of type: [CALCULATED] is allowed per template"
            }
          ]
        }
      },
      "UneditableSourceFieldError": {
        "value": {
          "errors": [
            {
              "code": "EMIS-003",
              "id": "EQ7CMX",
              "status": "400",
              "name": "UneditableSourceFieldError",
              "message": "Cannot modify uneditable source field: [sourceType] for source: [ds_users] of type: [EXTERNAL_INPUT]"
            }
          ]
        }
      },
      "InvalidSourceTypeValidationMessage": {
        "value": {
          "errors": [
            {
              "code": "EMIS-004",
              "id": "EQ7CMX",
              "status": "400",
              "name": "InvalidSourceTypeValidationMessage",
              "message": "Invalid source type: [INVALID_TYPE] for source: [ds_users]"
            }
          ]
        }
      },
      "IdentitySourceIDAlreadyExistsError": {
        "value": {
          "errors": [
            {
              "code": "EMIS-005",
              "id": "EQ7CMX",
              "status": "400",
              "name": "IdentitySourceIDAlreadyExistsError",
              "message": "Identity source with ID [ds_users] already exists in the import payload. ID must be unique."
            }
          ]
        }
      },
      "IdentitySourceDisplayNameAlreadyExistsError": {
        "value": {
          "errors": [
            {
              "code": "EMIS-006",
              "id": "EQ7CMX",
              "status": "400",
              "name": "IdentitySourceDisplayNameAlreadyExistsError",
              "message": "Identity source with Display Name [Users Table] already exists in the import payload. Display name must be unique."
            }
          ]
        }
      },
      "EnvironmentNotFoundError": {
        "value": {
          "errors": [
            {
              "code": "EMIT-003",
              "id": "EQ7CMX",
              "status": "404",
              "name": "EnvironmentNotFoundError",
              "message": "Environment: [2d4a0591-dfe4-45fb-8a69-d183f5c75c0d] doesn't exist"
            }
          ]
        }
      },
      "identityTemplateNotFound": {
        "value": {
          "errors": [
            {
              "code": "EMIT-002",
              "id": "EQ7CMX",
              "status": "404",
              "name": "IdentityTemplateNotFoundError",
              "message": "Identity Template: [User1] not found in Environment: [848aa1dd-3516-4dbe-b1bb-c32454302dc4], Hint: did you mean [User, Target]"
            }
          ]
        }
      },
      "PAAGroupNotFoundError": {
        "value": {
          "errors": [
            {
              "code": "EMIS-008",
              "id": "EQ7CMX",
              "status": "404",
              "name": "PAAGroupNotFoundError",
              "message": "PAA Group: [TestPAA] not found, Hint: did you mean: [TestPAA1, TestPAA2]"
            }
          ]
        }
      }
    }
  }
}
````

