---
title: "Generate Portfolio X-Ray"
description: "Overview of generating a portfolio X-Ray with the Portfolio X-Ray API, from authentication to interpreting results."
url: "https://developer-beta.morningstar.com/portfolio-xray-api/generating-portfolio-xrays"
image: "https://developer-beta.morningstar.com/_og/d/c_Ocean.takumi,title_~R2VuZXJhdGUgUG9ydGZvbGlvIFgtUmF5IHwgUG9ydGZvbGlvIFgtUmF5IEFQSQ,description_~T3ZlcnZpZXcgb2YgZ2VuZXJhdGluZyBhIHBvcnRmb2xpbyBYLVJheSB3aXRoIHRoZSBQb3J0Zm9saW8gWC1SYXkgQVBJLCBmcm9tIGF1dGhlbnRpY2F0aW9uIHRvIGludGVycHJldGluZyByZXN1bHRzLg,props_eyJ0aGVtZSI6eyJtb2RlIjoibGlnaHQiLCJjb2xvcnMiOnsicHJpbWFyeSI6IiMwMDAwMDAifX19,p_Ii9wb3J0Zm9saW8teHJheS1hcGkvZ2VuZXJhdGluZy1wb3J0Zm9saW8teHJheXMi,s_XVewbP9-00wUs5LQ.png"
---

-   [APIs](https://developer-beta.morningstar.com/apis)
-   [API Catalog](https://developer-beta.morningstar.com/api-catalog)
-   [API Assistant MCP Server](https://developer-beta.morningstar.com/api-assistant-mcp)
-   [Guides](https://developer-beta.morningstar.com/api-guides)
-   [Trial Access](https://developer-beta.morningstar.com/trial-access)

# Portfolio X-Ray API

Build Portfolio X-Ray APIs into your digital experience for quick investment and earnings summaries.

# Generating Portfolio X-Rays

[View Markdown](https://developer-beta.morningstar.com/portfolio-xray-api/generating-portfolio-xrays.md)[Download Markdown](https://developer-beta.morningstar.com/portfolio-xray-api/generating-portfolio-xrays.md)

The Portfolio X-Ray API analyzes one or two portfolios and returns how each is diversified by region, sector and investment style, along with holdings, fee, return and risk data. A single endpoint, `POST /portfolioanalysis/v1/xray`, handles every request.

## [Workflow](#workflow)

Generating an X-Ray follows these steps.

1.  **Get an access token.** Request a token from the Authentication API and include it in the `Authorization` header. See [Getting Started](https://developer-beta.morningstar.com/portfolio-xray-api/getting-started).
2.  **Build the request.** Define up to two portfolios, identify each holding and size each position. See [Request Structure](https://developer-beta.morningstar.com/portfolio-xray-api/request-structure).
3.  **Configure the analysis.** Choose a view, set the analysis period and add optional data sections. See [Configuring the Analysis](https://developer-beta.morningstar.com/portfolio-xray-api/configure-an-analysis).
4.  **Send the request.** Post the request body to the endpoint. See [Request Portfolio X-Ray](https://developer-beta.morningstar.com/portfolio-xray-api/request-portfolio-xray).
5.  **Read the response.** Each portfolio returns as one object in the `XRay` array. See [Understanding the Response](https://developer-beta.morningstar.com/portfolio-xray-api/response-structure).

## [Analyzing One or Two Portfolios](#analyzing-one-or-two-portfolios)

You can send one portfolio to analyze it on its own, or two portfolios in the same request. When you send two, you can align their analysis periods so that the results are comparable. See [Compare Two Portfolios](https://developer-beta.morningstar.com/portfolio-xray-api/compare-two-portfolios).

## [In This Section](#in-this-section)

| Page                    | Description                                                                      |
| :---------------------- | :------------------------------------------------------------------------------- |
| Request Portfolio X-Ray | The endpoint, parameters, a complete example request and the possible responses. |
| Compare Two Portfolios  | How to send two portfolios and align their analysis periods.                     |